# Scopes added during login aren't appearing in access token

**URL:** <https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755>\
**Category:** Get Help\
**Tags:** organizations, scopes, login\
**Created:** [May 19, 2022, 4:33pm UTC](https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755 "2022-05-19T16:33:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![illusionfactory](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/illusionfactory/32/36927_2.png) [@illusionfactory](https://community.auth0.com/u/illusionfactory)\
**Post date:** [May 19, 2022, 4:33pm UTC](https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755/1 "2022-05-19T16:33:52Z")

</div>

Hello out there!

I’m using SDK auth0/nextjs-auth0 ^1.7.0 in a nextjs app. In handle login, the scope ‘read:organizations’ is added.

```
      await handleLogin(req, res, {
        authorizationParams: {
          audience: audience,
          scope: 'openid profile read:organizations',
          redirect_uri
        },
        returnTo: '/home'
      })

```

handleCallback() is called after successful auth. In afterCallback() i check for the auth’d user’s scopes by decoding the access token.

```
await handleCallback(req, res, { 
  afterCallback,
   redirectUri
})

const afterCallback = async (req, res, session, state) => {
  const accessTokenDecoded = jwtDecode(session.accessToken)
  console.log("accessToken is ", accessTokenDecoded)
}

```

The scope is missing ‘read:organizations’

```
accessToken is {
  ...
  scope: 'openid profile'

```

Any idea how to get the scope to have ‘read:organizations’? After login, the user will want to be able to get information about the organization they just logged into. Thanks for any help.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 20, 2022, 12:39am UTC](https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755/3 "2022-05-20T00:39:19Z")

</div>

Hi there @illusionfactory welcome to the community!

> [@illusionfactory](#):
>
> Any idea how to get the scope to have ‘read:organizations’? After login, the user will want to be able to get information about the organization they just logged into.

Good question! Is this scope a permission for your own API? That is, in `authorizationParams` are you setting the audience to your own API that you have [registered in Auth0](https://auth0.com/docs/get-started/auth0-overview/set-up-apis) or are you looking to use the [Management API](https://auth0.com/docs/api/management/v2) in some way from your app?

Let us know!

---

<div class="post-metadata">

**Author:** ![illusionfactory](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/illusionfactory/32/36927_2.png) [@illusionfactory](https://community.auth0.com/u/illusionfactory)\
**Post date:** [May 20, 2022, 3:28pm UTC](https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755/5 "2022-05-20T15:28:42Z")

</div>

Hi tyf, thanks for the response.

Am trying to retrieve an organization by id using the Management Api here:

> **[Retrieve Organizations](https://auth0.com/docs/manage-users/organizations/configure-organizations/retrieve-organizations#retrieve-organization-by-id)**
>
> Learn how to retrieve Organizations using the Auth0 Dashboard and Management API.

The Api call looks like:

```
https://<DOMAIN>/api/v2/organizations/<ORG_ID>

```

Audience and Scope in Access Token after login is:

```
aud: [
  'https://<DOMAIN>/api/v2/',
  'https://<DOMAIN>/userinfo'
]
scope: 'openid profile'

```

Am trying to get auth’d with scope ‘openid profile read:organizations’ and use the resulting Access Token as the Bearer token to /api/v2/organizations Api.

```
const bearer = `Bearer ${accessToken}`
const headers = { authorization: bearer }

```

Is this possible or should I be taking a different approach? Thanks for the help.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 21, 2022, 1:04am UTC](https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755/7 "2022-05-21T01:04:48Z")

</div>

No problem, happy to help where I can!

> [@illusionfactory](#):
>
> Is this possible or should I be taking a different approach?

Thanks for clarifying your use case - I don’t believe this is possible as is. I recommend taking a look at our documentation around [Management API Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/management-api-access-tokens) and in particular [Management API Access tokens for production](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-access-tokens-for-production). Basically, this would be a separate backend process that has no user (client credentials) for which the resulting access token can be used at `https://<DOMAIN>/api/v2/organizations/<ORG_ID>`.

Hopefully this helps!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 5, 2022, 1:05am UTC](https://community.auth0.com/t/scopes-added-during-login-arent-appearing-in-access-token/83755/8 "2022-06-05T01:05:02Z")

</div>

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