Nextjs app sending opaque token to my API

Hi, I have a Java Spring Boot backend API and a Nextjs frontend app. After logging in, I try to access a protected endpoint and see this error in my API: Caused by: org.springframework.security.oauth2.jwt.BadJwtException: An error occurred while attempting to decode the Jwt: Encrypted JWT rejected: No JWE key selector is configured.

I see from previous topics that this is due to the access token being opaque. I checked to make sure I am sending the correct audience:

export default handleAuth({
  login: handleLogin({
    authorizationParams: {
        audience: 'https://lingua-books.com',
        scope: 'openid offline_access' 
    }
  })

Here is where I make the API call with the token:

const config = {
        headers: { Authorization: `Bearer ${accessToken}` }
     };

      // Make a POST request to your Java backend API
      const response = await axios.post(
        `${process.env.NEXT_PUBLIC_API_URL}/sellers`,
        sellerData,
        config
      );

I used the Authentication API Debugger, as in the video about audiences and received a proper token with aud in it. Am I missing some additional config in my nextjs app?

UPDATE: This was fixed by adding a default audience in my auth0 dashboard.

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