Nextjs13 Auth0 accesstoken missing the JWT Payload

I’m creating an NEXTJS APP with version 13.4. i have integrated the Auth0. My access_token comes with empty payload

Here’s my handleAuth fn


const redirectUri = `${process.env.AUTH0_BASE_URL}/api/page-router-auth/callback`;
const audience = `${process.env.AUTH0_ISSUER_BASE_URL}/api/v2/`;


export default pageRouterAuth.handleAuth({
  login: pageRouterAuth.handleLogin({
    authorizationParams: { 
      redirect_uri: redirectUri,
      audience: audience,
      scope: process.env.REACT_APP_AUTH0_SCOPE    
    }
  }),
  callback: pageRouterAuth.handleCallback({ redirectUri }),
  logout: pageRouterAuth.handleLogout({ returnTo: `${process.env.AUTH0_BASE_URL}/page-router` })
});

And here’s my withPageAuthRequired call

export default withPageAuthRequired(async function page(req: any, res: any) {
  
  const {accessToken} = await getAccessToken(req, res, {
    scopes: ['openid profile email read:current_user update:current_user_metadata read:users_app_metadata update:users']
  });

  console.log(accessToken);

  return (
    <div></div>
  )
}

What i’m doing wrong here???

1 Like