- 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:
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:
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:
const { accessToken } = await getAccessToken(req, res, {
scopes: ['read:users'],
});
Any help or guidance would be appreciated!