`getAccessTokenSilently` doesn't seem to respect `scope` option
See original GitHub issueWhat was the expected behavior?
when i specify the scope
option of getAccessTokenSilently
it should generate a JWT with the different scope
Reproduction
Detail the steps taken to reproduce this error, and whether this issue can be reproduced consistently or if it is intermittent. Note: If clear, reproducable steps or the smallest sample app demonstrating misbehavior cannot be provided, we may not be able to follow up on this bug report.
- clone https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01
- modify the
getAccessTokenSilently
to get a different scope, e.g.const token = await getAccessTokenSilently({ audience: 'https://orgs-beta-temporal.us.auth0.com/api/v2/', scope: 'default:admin', });
- observe that the returned JWT sees NO change in scope. it is still the default
"openid profile email"
2.5 minute Video recording of bug
https://www.loom.com/share/2a56bb28f8524984825a08a7eaeb237c
Environment
Please provide the following:
- Version of
auth0-react
used: 1.1.0 - Which browsers have you tested in? chrome
- Which framework are you using, if applicable (Angular, React, etc): react
- Other modules/plugins/libraries that might be involved: no
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Query about invoking gettiingaccessTokenSilently() with ...
When I want to invoke an endpoint on my backend that requires only p1, can I invoke getAccessTokenSilently with a scope of 'p1'?...
Read more >Auth0 Ignores Scope Option - ADocLib
The /oauth/token returns both access token and IDToken if I define scope as But ... to specific information doesn't appear only in All...
Read more >Github Com Auth0 Auth0 React Issues 183 - Alvindayu.com
`getAccessTokenSilently` doesn't seem to respect `scope` option - GitHub ... checklist of things to check when dealing with scopes in Auth0.
Read more >Access token appears to be incorrect format using auth0-react ...
So, in the options object of getAccessTokenSilently , make sure: the scope parameter includes openid; the audience parameter refers to your API.
Read more >Beginner's Thread / Easy Questions (December 2020) : r/reactjs
React class components seem to be the correct way to go? ... So if one of the data items you pass to the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yes, in particular i didn’t understand that
getAccessTokenSilently
’sscope
arg is for scope narrowing, and we need to declare all scopes the app needs at theAuth0Provider
level first.Here is a short checklist of things to check when dealing with scopes in Auth0. When you add a new scope:
api-server.js
, make sure it checks the right scope<Auth0Provider>
has the scope arg with the permission.getAccessTokenSilently
ONLY IF you want to narrow the scope from what you gave for<Auth0Provider>
This is so complicated because we need to model situations like this:
thanks so much to Frederik for his very dedicated and responsive help!!
Just to add a little nuance for this, this is for ensuring the user has given consent. When you are skipping consent for first party applications, this is not realy required, but yet I think it is a good practise to do so (it avoids you having to think about first vs third party apps).
Just to avoid confusion, it should be the other way around. You can not set the USER’s permissions if you haven’t set the API’s permissions. So start with the API, then the USER.