# Jwt missing scope

**URL:** <https://community.auth0.com/t/jwt-missing-scope/77558>\
**Category:** JWT.io\
**Tags:** scopes\
**Created:** [February 3, 2022, 7:49am UTC](https://community.auth0.com/t/jwt-missing-scope/77558 "2022-02-03T07:49:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![g.padres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/g.padres/32/17100_2.png) [@g.padres](https://community.auth0.com/u/g.padres)\
**Post date:** [February 3, 2022, 7:49am UTC](https://community.auth0.com/t/jwt-missing-scope/77558/1 "2022-02-03T07:49:00Z")

</div>

Hi,

We are creating staging environments, and while replicating our dev environment (with corresponding Auth0 tenant) we noticed that requested scopes were not being present in the JWT (as in our dev env). We’ve done research into why this is happening and can’t find a cause. RBAC is enabled, user has the requested permission, but the scope in the access token does not include it. Any ideas of what could be missing? Thanks beforehand!

/Guillermo

---

<div class="post-metadata">

**Author:** ![g.padres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/g.padres/32/17100_2.png) [@g.padres](https://community.auth0.com/u/g.padres)\
**Post date:** [February 3, 2022, 9:57pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/2 "2022-02-03T21:57:51Z")

</div>

Update: we have a react single page application (using Auth0 SDK) and this works fine (e.g. access token has required scopes) in development mode. When building though (using yarn), getAccessTokenSilently replies the JWT without the requested scopes (that I am sure the user has). Is there any issues with yarn build and the Auth0 SDK for React? We are serving the single webapp through nginx

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 3, 2022, 10:05pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/4 "2022-02-03T22:05:28Z")

</div>

Hi @g.padres,

Are you seeing a permissions array in the access token? If not, can you give us an example of the Access Token you are seeing?

_Helpful tip: replying to your own support topic removes it from our unanswered queue._

---

<div class="post-metadata">

**Author:** ![g.padres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/g.padres/32/17100_2.png) [@g.padres](https://community.auth0.com/u/g.padres)\
**Post date:** [February 3, 2022, 11:17pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/5 "2022-02-03T23:17:28Z")

</div>

Hi Dan,

I managed to understand the problem. The scopes are a string with spaces in the environment file. We added double quotes to the entry in the env file. In development mode, the quotes are passed as a string. When building though, the quotes are added another quote, so Auth0 is getting the scopes with 3 quotes, something like a quoted string or similar. I suspect this is the reason we are not getting any scopes back. When taking away the quotes on the env file it works fine, but I suppose it’s better to leave the quotes and process to take away extra quotes before sending scopes.

Thoughts?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 3, 2022, 11:18pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/6 "2022-02-03T23:18:23Z")

</div>

Do you have an example?

---

<div class="post-metadata">

**Author:** ![g.padres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/g.padres/32/17100_2.png) [@g.padres](https://community.auth0.com/u/g.padres)\
**Post date:** [February 3, 2022, 11:22pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/7 "2022-02-03T23:22:56Z")

</div>

in env file

```auto
REACT_APP_AUTH0_SCOPE="admin user"

```

In react, scopes variable that serves as input to initialize Auth0 provider:

```auto
const scopes = process.env.REACT_APP_AUTH0_SCOPE;

```

Digging through the built js files, I found the following lines:

```auto
REACT_APP_AUTH0_SCOPE:'"admin user"'

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 3, 2022, 11:49pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/8 "2022-02-03T23:49:48Z")

</div>

I don’t think .env files typically include quotes for strings. You could also do as we do in our examples and use an [auth\_config.json](https://github.com/auth0-samples/auth0-react-samples/blob/master/Sample-01/src/auth_config.json.example) file.

---

<div class="post-metadata">

**Author:** ![g.padres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/g.padres/32/17100_2.png) [@g.padres](https://community.auth0.com/u/g.padres)\
**Post date:** [February 4, 2022, 12:56pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/9 "2022-02-04T12:56:06Z")

</div>

We left the env file variables with quotes (a couple of articles point that is better practice that way) and we are correctly parsing them in our JS code. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 4, 2022, 9:13pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/10 "2022-02-04T21:13:12Z")

</div>

Great. Thanks for following up with your solution!

---

<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:** [February 19, 2022, 9:13pm UTC](https://community.auth0.com/t/jwt-missing-scope/77558/11 "2022-02-19T21:13:16Z")

</div>

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