gleX
gleX

Reputation: 595

Oauth2 authentication failed

I'm trying to use spring OAUTH2sso in my application (client) with an oauth2 provider that have installed. With the client configured in the oauth2 provider and with the clientId, clientSecret, accessTokenUri and userAuthorizationUri configured in the client, when an user are authenticated and authorize the client and after the redirection, the client show me an error of authentication failed because the springOauth2sso library does not get the user details.

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Thu Jan 21 10:28:28 CET 2016 There was an unexpected error (type=Unauthorized, status=401). Authentication Failed: Could not obtain user details from token

I tested my provider with other oauth2 libraries and it was pretty well but I'm not sure about what happened in this case.

Upvotes: 1

Views: 7406

Answers (1)

JIMI
JIMI

Reputation: 449

This error can have a lot of different meaning as it is a wrapper for InvalidTokenException.

Your token can be invalid, expired or there might be a problem with your client or even a problem when retrieving UserDetails.

To get more info about this problem I recommend debugging and placing a debugging point straight to the source of this error OAuth2ClientAuthenticationProcessingFilter. At line 99 this filter is trying to load authentication from ResourceServerTokenServices implementation and if you step into that call you will find out what's causing your error.

Also I'm not sure I understood your configuration correctly but I suppose you might need one of these two properties:

security.oauth2.resource.token-info-uri
security.oauth2.resource.user-info-uri

More info here: Spring Boot Docs

Upvotes: 2

Related Questions