# Nextjs-auth0 read:users not being returning in access token

**URL:** <https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839>\
**Category:** Get Help\
**Created:** [November 9, 2021, 3:47pm UTC](https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839 "2021-11-09T15:47:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel.vinihan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/daniel.vinihan/32/32863_2.png) [@daniel.vinihan](https://community.auth0.com/u/daniel.vinihan)\
**Post date:** [November 9, 2021, 3:47pm UTC](https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839/1 "2021-11-09T15:47:47Z")

</div>

- **Which SDK this is regarding:** e.g. auth0-node
- **SDK Version:** e.g. 2.29.0
- **Platform Version:** e.g. Node 12.19.0
- **Code Snippets/Error Messages/Supporting Details/Screenshots:**

I’m using the @auth0/nextjs-auth0 library, and despite having poured over the docs and forum topics, I cannot get my Nextjs app to retrieve an access token with the read:users scope granted.

I believe I’ve configured my app as described in the docs, and I’ve added the read:users scope to my Auth0 Management API on the Auth0 dashboard. I’ve even tried adding an AUTH0\_AUDIENCE (although I’m still not sure if that’s needed?).

Does anyone have any advice on what I might possibly be doing wrong?  
I have the following configured in my .env.local:

```auto
AUTH0_SECRET=<secret>
AUTH0_BASE_URL=http://localhost:3000
AUTH0_ISSUER_BASE_URL=https://<my url>.us.auth0.com
AUTH0_CLIENT_ID=<client id>
AUTH0_CLIENT_SECRET=<secret>
AUTH0_AUDIENCE=<identifier from Auth0 dashboard>

```

And in pages/api/auth/[…auth0].ts, I have this:

```auto

import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';
import { NextApiRequest, NextApiResponse } from 'next';

export default handleAuth({
  login: async (req: NextApiRequest, res: NextApiResponse) => {
    try {
      await handleLogin(req, res, {
        authorizationParams: {
          audience: process.env.AUTH0_AUDIENCE,
          scope: 'openid profile email read:users',
        },
      });
    } catch (error) {
      res.status(error.status || 400).end(error.message);
    }
  },
});

```

I’ve even tried specifically requesting the scope when I get the access token that I will use for the management API call:

```auto
  const { accessToken } = await getAccessToken(req, res, {
    scopes: ['read:users'],
  });

```

Any help or guidance would be appreciated!

---

<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:** [November 15, 2021, 10:04pm UTC](https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839/3 "2021-11-15T22:04:20Z")

</div>

Hi @daniel.vinihan,

Welcome to the Auth0 Community!

The next js SDK is not meant to be a Management API client. You can get management API tokens with limited scopes, but will want to use the node-auth0 management client with a client credentials grant to get a management API token.

There is an example in this doc that includes how to do it:

> **[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.

---

<div class="post-metadata">

**Author:** ![daniel.vinihan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/daniel.vinihan/32/32863_2.png) [@daniel.vinihan](https://community.auth0.com/u/daniel.vinihan)\
**Post date:** [November 16, 2021, 4:08pm UTC](https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839/4 "2021-11-16T16:08:20Z")

</div>

Thanks Dan. I did eventually figure this out on my own. I had assumed the nextjs-auth0 library would handle this, when in fact it did not- and there was my mistake. Thank you!

---

<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:** [November 16, 2021, 9:39pm UTC](https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839/5 "2021-11-16T21:39:03Z")

</div>

Great. Thanks for following up!

---

<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:** [December 1, 2021, 9:40pm UTC](https://community.auth0.com/t/nextjs-auth0-read-users-not-being-returning-in-access-token/72839/6 "2021-12-01T21:40:03Z")

</div>

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