Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use amazon-cognito-identity-js to get scopes in the access_token? #1884

Closed
andrej-vasilj opened this issue Oct 11, 2018 · 14 comments
Closed
Labels
Cognito Related to cognito issues question General question

Comments

@andrej-vasilj
Copy link

** Which Category is your question related to? **
amazon-cognito-identity-js

** What AWS Services are you utilizing? **
AWS Cognito User Pools

** Provide additional details e.g. code snippets **
How do I use amazon-cognito-identity-js to get the scopes in the access_token? When I login using the web sign-in page I can see all default and custom scopes inside the access token, but when I use amazon-cognito-identity-js I get only the admin scope and nothing else.

@powerful23 powerful23 added Cognito Related to cognito issues question General question labels Oct 11, 2018
@powerful23
Copy link
Contributor

@andrej-vasilj can you try accessToken.decodePayload() to see if the payload contains any info about scopes?

@andrej-vasilj
Copy link
Author

I've been using https://jwt.io/ for quick debugging since it has a nice visual interface to decode tokens. The 'scope' section of the access token is always set to 'aws.cognito.signin.user.admin'. Today I was also trying to use boto3 for Python instead of javascript and I'm running into the same situation. It doesn't even matter if I deselect the 'aws.cognito.signin.user.admin' scope directly in the Cognito web admin console, it still gets listed in the access token. I'm really stuck and I don't know what to try...

@powerful23
Copy link
Contributor

@andrej-vasilj I think the scope setting in the Cognito web admin console is only effective for OAuth(Cognito Hosted UI). @yuntuowang what do you think?

@ErikCH
Copy link

ErikCH commented Oct 31, 2018

I'm having a similar issue, I moved from Cognito hosted to the Amplify libraries, and looking at the jwt token, I don't see the scopes in it (other then aws.cognito.signin.user.admin). Maybe I have something setup wrong...

@powerful23
Copy link
Contributor

@ErikCH as I know for now the scope would only be aws.cognito.signin.user.admin, there is no other scopes in the access token given from Cognito.

@powerful23
Copy link
Contributor

Closing the issue due to no further response. Feel free to reopen if you still have this issue.

@fcouceiro
Copy link

Is there any improvements on this?
Maybe I am looking at this the wrong way, but how would I access an API Gateway resource that accepts specific scopes without having the scopes in the token? 🤔

Also, what are the implications of having "aws.cognito.signin.user.admin" in it? I do not want my end users to end up with access to cognito APIs. Is this the case?

I am bit frustrated about this documentation mess that Amplify brought. Old documentation no longer applies, new documentation does not cover edge cases. New sdks do not support most of the features.

Any help would be much appreciated. 🙂

@garlic0708
Copy link

garlic0708 commented Mar 5, 2019

Since we cannot have scopes associated with access tokens given in non-OAuth 2.0 ways, I wonder if there is any alternative, maybe less delicate way, as a compromise, to do 'scope' management with it?

@jonvanputten
Copy link

Any update on this? A roadmap or anything giving information on getting custom scopes from the access_token?

@powerful23
Copy link
Contributor

@jonvanputten since this is an issue/request about the Cognito service, we can't give any roadmap or statement here. It would be more efficient if you can go to the AWS forum and submit this issue to the service team directly. Thanks for your understanding!

@hanslai
Copy link

hanslai commented Jul 25, 2019

I do not think this is a Cognito issue, since I was able to get the scopes with token endpoint with Postman, just Amplify is not returning the necessary scopes. Please refer to #3732.

Yet the .Net Cognito API was having the same problem as well and it also use SPR to sign in.

@DavidWells
Copy link

Was anyone able to solve this?

Is the answer to use https://github.com/aws-amplify/amplify-js/tree/master/packages/amazon-cognito-identity-js & re-implement Auth.login from amplify with the base library?

@ddbradshaw
Copy link

IMO - this is an issue because you must have a cognito pool app client with a client secret in order to use scopes. And unfortunately, the amplify javascript sdk doesn't support client secrets (because that would leak the secret out).

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Cognito Related to cognito issues question General question
Projects
None yet
Development

No branches or pull requests

9 participants