Expand my Community achievements bar.

SOLVED

OAuthAuthenticationHandler extractCredentials: fallback to we can't handle this

Avatar

Level 1

Hi,

 

I've implemented a custom OAuth Provider and API. 

So currently AEM redirects to OAuth form, and after successful login user is redirected back to AEM with

authorization_code as a parameter 
http://localhost:4503/content/site/en/welcome.html?code=W8kJTZV9syQJ8JOuPWMTCeP_x2C190y-9CmWehunGpM&state=s5vraqvk34thmc5koifac1kbla

The problem is that OAuthAuthenticationHandler doesn't see authorization_code as a request param:

com.adobe.granite.auth.oauth.impl.OAuthAuthenticationHandler extractCredentials: fallback to we can't handle this

 as a result, there is the following error in logs:

com.adobe.granite.auth.oauth.impl.helper.OauthTokenManager token not found in request attribute or cookie for:customOAuth

 

Why code param is not visible for OAuthAuthenticationHandler? How could it be debugged to understand the root cause of this issue?

 

Thank you in advance!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Are you using JsonTokenExtractor?

 

Login form should redirect to url that ends with "/callback/j_security_check"

that triggers AEM code to make an additional call to OAuth service to get Access Token

 

Refer to the below URL for more detail -

https://github.com/techforum-repo/bundles/blob/master/google-oauth-provider/src/main/java/com/core/o...

https://techforum.medium.com/social-login-with-google-oauth2-adobe-experience-manager-aem-ff33b5c4f3...

Regards

Albin I

www.albinsblog.com

 

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Are you using JsonTokenExtractor?

 

Login form should redirect to url that ends with "/callback/j_security_check"

that triggers AEM code to make an additional call to OAuth service to get Access Token

 

Refer to the below URL for more detail -

https://github.com/techforum-repo/bundles/blob/master/google-oauth-provider/src/main/java/com/core/o...

https://techforum.medium.com/social-login-with-google-oauth2-adobe-experience-manager-aem-ff33b5c4f3...

Regards

Albin I

www.albinsblog.com

 

Avatar

Level 1

Hi Albin,

Thanks for response!

I am not using JsonTokenExtractor. I followed same link that you provided.

From the logs i see that AEM tries to find authorization_code in request before request comes back from OAuth login page.

so log looks like this:

com.adobe.granite.auth.oauth.impl.helper.OauthTokenManager token not found in request attribute or cookie for:custom_config
GET /content/redirect/path.html?code=CodeFromTheOAuth&state=some_state HTTP/1.1

 

Avatar

Employee

Hi @maksyms28136728 

I am facing exactly same error where the call to token endpoint is not made after redirect to callback url with auth code as parameter. Were you able to resolve this issue?

Any help is highly appreciated, thanks. 

Avatar

Level 1

Hello @Albin_Issac 

I followed your approaches in https://github.com/techforum-repo/aem-bundles

I already configured the callback url  http://localhost:4502//callback/j_security_check

I do the login in form of provider, the callback works and when came back the function in OauthServiceImpl-> getAccessToken it's called

And i do a request to get the access token, so far so good, i get the access token and return the token.

The next step is call getProtectedDataRequest in implementation of custom provider.

But in this function above i need to send the access token in authorization header, how to do this? because in this moment i can't access the access token that was catches in previous step.

 

I check the logs and i see this info:

*INFO* [qtp204841818-1386] com.adobe.granite.auth.oauth.impl.helper.OauthTokenManager token not found in request attribute or cookie for:

 

Thanks

Avatar

Level 1

I found the issue.

Login form should redirect to url that ends with "/callback/j_security_check"

that triggers AEM code to make an additional call to OAuth service to get Access Token