I want to enable service to service authentication in my services using spring boot and azure oauth2.I have generated access token using
https://login.microsoftonline.com//oauth2/token (POST)
I want to validate that whenever my service is hit with this access token , it should the request or throw 403.It is always throwing 403.
Hitting after putting header : Authorization -> Bearer access_token
@EnableWebSecurity
@Configuration
public class WebAuthentication extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/subordinate").permitAll();
http.authorizeRequests().antMatchers("/api/**").authenticated();
}
}
What should be added to validate service based authentication token.(No user is involved in generating token)