How to set up the Audience in Next.js SDK to get a valid JWT?

Hi,

I’m moving our App from React to Next.js, everything worked fine with the React SDK. But now, using the Next.js SDK I’m not able to get a valid JWT, just getting an opaque token…

I’m trying to find a way to set the Audience during Login to get a valid JWT, like I did in React, but can’t find how to do that.

Even in the doc for authorizationParams, there is no audience params… AuthorizationParams | @auth0/nextjs-auth0

Can someone help me with this ?

Many thanks.

I also added AUTH0_AUDIENCE to the .env.local with the other params but that seems to be ignored…

Does anyone know about that issue ?

Hey @raph1 welcome to the community!

Hmm thanks for pointing this out - The audience param should indeed be added to AuthorizationParams:

@tyf Thanks for you reply.

I was finally able to get a valid JWT token by passing manually the audience to in the AuthorizationParams.

But now I have another issue… This JWT is NOT recognized as a valid token by my Flask Server.

It was working perfectly well (and still works) with my React Client. The setup is the same, same audience etc… when I look inside the JWT token with jwt.io I find the same informations…

But for some reason the Token received in my Next.js app isn’t accepted by my server while the token received in my React App is accepted.

Any idea of what’s going on ?

1 Like

That’s great, thanks for confirming!

Very odd! Is your Flask server throwing any error in particular when attempting to verify the token?