I have a separate ResourceServer built using Spring-Security-oauth2. Here is the code RemoteTokenService.
@Bean
public ResourceServerTokenServices tokenService()
I have the following configuration:
@Configuration
@EnableWebSecurity
@EnableAuthorizationServer
public class OAuthSecurityConfig extends AuthorizationServerConfigurerAdapter {
// ...
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
// (!)
oauthServer.allowFormAuthenticationForClients();
}
// ...
I added the following line:
oauthServer.checkTokenAccess("permitAll()");
into the line with "(!)" to fix the same problem.