Access token is showing unauthorised

We are using await auth0Client.getTokenWithPopup(options) to get access token. But when we do server side validation to call Auth0 management api, it returns the error “unauthorised”. What we can do to resolve this issue?

Please ignore it. I was not using correct client ID. Now it is working. Thanks

Hi @v-chetan , thank you for posting!

If you request an access token from an SPA app (auth0Client.getTokenWithPopup(options)) to call the Management API, you need to specify relevant for the current user scopes. These scopes are listed here.

An example would look like this:

auth0Client.getTokenWithPopup({
authorizationParams: {
   "audience":"https://your_auth0_domain/api/v2/",
   "scope": "read:current_user update:current_user_metadata"}
})

Scope property is a string with space-separated scopes.

Ref: GetTokenWithPopupOptions | @auth0/auth0-spa-js

Please let us know if that helped or if you have any questions!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.