Spring security OAuth - check validity of access token?

brain storm picture brain storm · Jul 24, 2015 · Viewed 11k times · Source

I am following this sample code from Spring Security OAuth.

After I got the access token when I try to check the token

curl -X POST http://localhost:9999/uaa/oauth/check_token -d "token=e3f44c4f-f8f2-45c4-9f9e-c7dd1f583a1f"

I get the following error:

{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}

I tried passing client id and secret.

curl -X POST acme:acmesecret@localhost:9999/uaa/oauth/check_token -d "token=e3f44c4f-f8f2-45c4-9f9e-c7dd1f583a1f"

I get 403 status.

{"timestamp":1437683976536,"status":403,"error":"Forbidden","message":"Access is denied","path":"/uaa/oauth/check_token”}

I am unable to figure out what is going wrong. Any help here is much appreciated.

Answer

nKognito picture nKognito · Aug 3, 2015

Try to play with /check_token authorization rights via:

public class OAuthSecurityConfig extends AuthorizationServerConfigurerAdapter {
   @Override 
   public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { 
       oauthServer.checkTokenAccess("permitAll()"); 
   }
}