# Auth0-js : can't set scope

**URL:** <https://community.auth0.com/t/auth0-js-cant-set-scope/43162>\
**Category:** Get Help\
**Created:** [May 17, 2020, 12:01pm UTC](https://community.auth0.com/t/auth0-js-cant-set-scope/43162 "2020-05-17T12:01:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saytaine](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saytaine/32/12846_2.png) [@saytaine](https://community.auth0.com/u/saytaine)\
**Post date:** [May 17, 2020, 12:01pm UTC](https://community.auth0.com/t/auth0-js-cant-set-scope/43162/1 "2020-05-17T12:01:11Z")

</div>

Hello,

I want to be able to update user metadata. When i send a `PATCH` request i get in return : `Insufficient scope, expected any of: update:users,update:users_app_meta`, which seem pretty clear.

Then I update my login function in my front, and add the required scope :

> const options = {  
> scope: ‘openid profile offline\_access read:current\_user read:current\_user\_metadata update:users\_app\_meta’,  
> audience: `https://<my-tenant>.eu.auth0.com/userinfo`,  
> responseType: ‘code’  
> };

but when I decode the acces\_token, I dont have the new scope I added.

> {  
> “iss”: “https:// .eu.auth0.com/”,  
> “sub”: “auth0|5da4…e74988198”,  
> “aud”: [  
> “https://.eu.auth0.com/api/v2/”,  
> “https://.eu.auth0.com/userinfo”  
> ],  
> “iat”: 1589716264,  
> “exp”: 1589719864,  
> “azp”: “V3KIi…aN”,  
> “scope”: “openid profile offline\_access” \<----- no update:users\_app\_meta  
> }

AS you can see, even my other added scopes (s read:current\_user read:current\_user\_metadata) doesn’t appears here, can you help me figure it out ?

Thanks

---

<div class="post-metadata">

**Author:** ![rashid779939](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rashid779939/32/27027_2.png) [@rashid779939](https://community.auth0.com/u/rashid779939)\
**Post date:** [May 18, 2020, 8:17am UTC](https://community.auth0.com/t/auth0-js-cant-set-scope/43162/2 "2020-05-18T08:17:55Z")

</div>

Hi @saytaine,

We need some more details regarding you issue. Would you please mention which token you using when going for patch call?

---

<div class="post-metadata">

**Author:** ![saytaine](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saytaine/32/12846_2.png) [@saytaine](https://community.auth0.com/u/saytaine)\
**Post date:** [May 18, 2020, 8:34am UTC](https://community.auth0.com/t/auth0-js-cant-set-scope/43162/3 "2020-05-18T08:34:38Z")

</div>

Hi @rashid779939  
I used acces\_token.  
I tried with a generated test token from my dashboard and it works, because test token has every scope added

---

<div class="post-metadata">

**Author:** ![andy.carter](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andy.carter/32/27949_2.png) [@andy.carter](https://community.auth0.com/u/andy.carter)\
**Post date:** [May 18, 2020, 3:53pm UTC](https://community.auth0.com/t/auth0-js-cant-set-scope/43162/4 "2020-05-18T15:53:05Z")

</div>

Hi @saytaine,

It looks like you are trying to issue an access token to a user, using the authorization\_code grant, that can be then used to call the management API.

An access token for calling the management API needs to be issued to a backend process (not a user), using the client\_credentials grant:

> **[Get Management API Access Tokens for Production](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-access-tokens-for-production)**
>
> Learn how to get Access Tokens to make scheduled frequent calls to the Management API.

As a security note, when requesting an access token to all the management API with, only request the scopes you need for that request.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 2, 2020, 3:53pm UTC](https://community.auth0.com/t/auth0-js-cant-set-scope/43162/5 "2020-06-02T15:53:07Z")

</div>

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