# The getAccessToken in Nextjs returns opaque token instead of access token even after specifying the audience

**URL:** <https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [September 11, 2024, 2:58pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457 "2024-09-11T14:58:37Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishnukumart96](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vishnukumart96/32/60298_2.png) [@vishnukumart96](https://community.auth0.com/u/vishnukumart96)\
**Post date:** [September 11, 2024, 2:58pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/1 "2024-09-11T14:58:37Z")

</div>

I m having nextjs as my client and expressjs my backend, I am trying to get the accessToken in my nextjs app with the below code ( by specifying the audience )

//app/fetchToken  
import { NextResponse } from “next/server”;  
import { getAccessToken, withApiAuthRequired } from “@auth0/nextjs-auth0”;

const GET = withApiAuthRequired(async function GET(req) {  
const res = new NextResponse();  
const { accessToken } = await getAccessToken(req, res, {  
authorizationParams:{  
audience:process.env.AUTH0\_AUDIENCE,  
scope: ‘openid profile email’,  
}  
});  
console.log(accessToken);  
return NextResponse.json({ accessToken: accessToken }, res);  
});

export { GET };

The peoblem is the accessToken I get is an opaque token, but I need the actual access Token, Only then my server can validate it, Currently my server can’t validate this opaque token.

Also when I [jwt.io](http://jwt.io) to see the contents of this opaque token, it tells the opaque token is not in a valid signature.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/b/4/b4eac263479a34a199c407400064585240989783.png)  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/0/3/03fd6aa6a6b3fb515861dfd82550cb45cbe19838.png)

---

<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:** [September 11, 2024, 3:53pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/3 "2024-09-11T15:53:22Z")

</div>

Hey there @vishnukumart96 welcome to the community!

Thanks for sharing the details - Are you able to inspect the request `/authorize` request in the network tab of your browser’s developer tools to see if the `audience` param is indeed being passed? I suspect it’s being excluded one way or another.

Let us know!

---

<div class="post-metadata">

**Author:** ![vishnukumart96](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vishnukumart96/32/60298_2.png) [@vishnukumart96](https://community.auth0.com/u/vishnukumart96)\
**Post date:** [September 11, 2024, 4:19pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/4 "2024-09-11T16:19:55Z")

</div>

Can see that the audience is indeed being passed

![image](https://global.discourse-cdn.com/auth0/original/3X/9/3/93efe5aadd86d24ce931b6dd803e1a979f93fbeb.png)

---

<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:** [September 11, 2024, 9:45pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/5 "2024-09-11T21:45:57Z")

</div>

Thanks for checking! That’s super odd 🤔 Nothing in your code stick out to me immediately - Have you tested using the same config values in the Sample app? If not, I recommend doing so and comparing results:

> **[auth0-nextjs-samples/Sample-01 at main · auth0-samples/auth0-nextjs-samples](https://github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01)**
>
> Auth0 Integration Samples for Next.js Applications - auth0-samples/auth0-nextjs-samples

---

<div class="post-metadata">

**Author:** ![vishnukumart96](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vishnukumart96/32/60298_2.png) [@vishnukumart96](https://community.auth0.com/u/vishnukumart96)\
**Post date:** [September 12, 2024, 5:48am UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/6 "2024-09-12T05:48:14Z")

</div>

I have tested using the sample app and the case remains the same

---

<div class="post-metadata">

**Author:** ![vishnukumart96](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vishnukumart96/32/60298_2.png) [@vishnukumart96](https://community.auth0.com/u/vishnukumart96)\
**Post date:** [October 14, 2024, 2:23pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/7 "2024-10-14T14:23:15Z")

</div>

This still issue still persists and can’t find any solutions, any help on this would be much appreciated

---

<div class="post-metadata">

**Author:** ![Bogdan\_Naumenko](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bogdan_naumenko/32/62258_2.png) [@Bogdan\_Naumenko](https://community.auth0.com/u/Bogdan_Naumenko)\
**Post date:** [November 16, 2024, 8:20pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/8 "2024-11-16T20:20:25Z")

</div>

Any updates on this? Have the same issue by getting opaque token instead of jwt token byt passing correct audience param on authorizationParams. It looks like the client is not handle properly audience param passed to the constructor

---

<div class="post-metadata">

**Author:** ![Albinch](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albinch/32/70148_2.png) [@Albinch](https://community.auth0.com/u/Albinch)\
**Post date:** [January 8, 2025, 9:08pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/9 "2025-01-08T21:08:53Z")

</div>

Hi, any updates ? Facing the same issue here

---

<div class="post-metadata">

**Author:** ![htmlpapi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/htmlpapi/32/71298_2.png) [@htmlpapi](https://community.auth0.com/u/htmlpapi)\
**Post date:** [January 22, 2025, 6:46pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/10 "2025-01-22T18:46:47Z")

</div>

I’m having the same problem, has any of you been able to solve it?

---

<div class="post-metadata">

**Author:** ![woutvdwg](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woutvdwg/32/71099_2.png) [@woutvdwg](https://community.auth0.com/u/woutvdwg)\
**Post date:** [January 24, 2025, 12:38pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/11 "2025-01-24T12:38:04Z")

</div>

Experiencing the same issue here. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![sal.x](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sal.x/32/71203_2.png) [@sal.x](https://community.auth0.com/u/sal.x)\
**Post date:** [February 19, 2025, 4:35am UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/12 "2025-02-19T04:35:27Z")

</div>

I am facing this same issue. I am using nextjs-auth0 library and when I use auth0.getAccessToken() (after already authenticating) I get a jwt with no payload or Opaque. Any way to solve this?

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [February 19, 2025, 10:38pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/14 "2025-02-19T22:38:45Z")

</div>

Hi @vishnukumart96

Welcome to the Auth0 Community and I am sorry about the late reply to your inquiry!

For anyone who may be looking for a solution to this issue, I would recommend to review this community post regarding receiving an opaque access token:

- [@auth0/nextjs-auth0 tokens and external api help](https://community.auth0.com/t/auth0-nextjs-auth0-tokens-and-external-api-help/71072)

In general, an opaque access token is returned because the right `audience` or `scope` was not passed in as parameters, the application was not registered with the Management API or the right grants are not enabled for your application.

Usually, if you are using a custom API, you will need to register it within Your Auth0 Dashboard and then create an [M2M application](https://auth0.com/docs/get-started/auth0-overview/create-applications/machine-to-machine-apps) in order for your api to communicate with Auth0’s Management API.

You can also review our documentation about [Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/get-access-tokens#control-access-token-audience).

Hopefully, the provided information above is useful in resolving the issues you might encounter with opaque access tokens!

If you have any other questions, feel free to leave a reply or to post again on the community!

Kind Regards,  
Nik

---

<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:** [March 5, 2025, 10:38pm UTC](https://community.auth0.com/t/the-getaccesstoken-in-nextjs-returns-opaque-token-instead-of-access-token-even-after-specifying-the-audience/146457/15 "2025-03-05T22:38:58Z")

</div>

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