Search code examples
amazon-web-servicesoauthamazon-cognito

Not getting cognito Access token after login with amzon cognito domain UI (generated from userpool)?


I'm not getting the access token from aws cognito user pool after authentication, I'm getting code in web url instead of token.

The step I have done are following :-

Step 1: Created an User pool and setup all the requirements.

Step 2: Added Identity providers credential in userpool left navigation bar -> Federation -> Identity Providers(Facebook, google plus).

Step 3: Done Attribute mapping(User pool left Navigation bar -> Federation -> Attribute Mapping).

Step 4: Enabled Identity Providers and added callback URI(User pool left Navigation bar App Integration -> App Client Setting -> Enabled Identity Providers)(Allowed OAuth Flows -> Authorization code grant)

Step 5: Created URI domain name (User pool left Navigation bar App Integration -> Domain Name) and added this domain in Facebook app as well as in google plus account(https://XXXXXXXXX.auth.us-east-1.amazoncognito.com/oauth2/idpresponse).

Step 6: Open the hosted domain by aws in browser (https://XXXXXXXXX.auth.us-east-1.amazoncognito.com/login?response_type=code&client_id=abcdefghi&redirect_uri=https://abcdefg)

enter image description here

Step7: Login in into open UI and it redirect to successful login with an code in query parameter, not the access token how can I get the access token now in my application.

enter image description here

Please help me.


Solution

  • Authorization code grant flow will only vend an authorization code to your application. This code can be exchanged for tokens with the Cognito token endpoint.

    If you want tokens vended directly to your app, you should use Implicit grant flow instead.

    Reference documentation: http://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-app-idp-settings.html