Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"OperationProcessingError: unexpected JWT "aud" (audience) claim value" on Google Provider callback #10210

Open
BluSimmon opened this issue Mar 4, 2024 · 0 comments
Labels
bug Something isn't working providers triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@BluSimmon
Copy link

Provider type

Google

Environment

System:
OS: Windows 11 10.0.22621
CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11400F @ 2.60GHz
Memory: 2.87 GB / 15.87 GB
Binaries:
Node: 20.11.1 - C:\Program Files\nodejs\node.EXE
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (122.0.2365.59)
Internet Explorer: 11.0.22621.1
npmPackages:
@auth/prisma-adapter: ^1.5.0 => 1.5.0
next: 14.1.1 => 14.1.1
next-auth: ^5.0.0-beta.15 => 5.0.0-beta.15
react: ^18 => 18.2.0

Reproduction URL

https://github.com/BluSimmon/next-auth-google

Describe the issue

The error screen after Login with Google
image

Error in terminal

[auth][error] CallbackRouteError: Read more at https://errors.authjs.dev#callbackrouteerror
[auth][cause]: OperationProcessingError: unexpected JWT "aud" (audience) claim value
    at validateAudience (webpack-internal:///(rsc)/./node_modules/oauth4webapi/build/index.js:1063:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processGenericAccessTokenResponse (webpack-internal:///(rsc)/./node_modules/oauth4webapi/build/index.js:1030:32)
    at async Module.processAuthorizationCodeOpenIDResponse (webpack-internal:///(rsc)/./node_modules/oauth4webapi/build/index.js:1133:20)
    at async handleOAuth (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/actions/callback/oauth/callback.js:78:24)
    at async Module.callback (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/actions/callback/index.js:35:41)
    at async AuthInternal (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/index.js:42:24) 
    at async Auth (webpack-internal:///(rsc)/./node_modules/@auth/core/index.js:126:34)
    at async D:\next_auth\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:63809
    at async eU.execute (D:\next_auth\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:53964)
    at async eU.handle (D:\next_auth\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:65062)
    at async doRender (D:\next_auth\node_modules\next\dist\server\base-server.js:1334:42)        
    at async cacheEntry.responseCache.get.routeKind (D:\next_auth\node_modules\next\dist\server\base-server.js:1544:40)
    at async DevServer.renderToResponseWithComponentsImpl (D:\next_auth\node_modules\next\dist\server\base-server.js:1464:28)
    at async DevServer.renderPageComponent (D:\next_auth\node_modules\next\dist\server\base-server.js:1861:24)
    at async DevServer.renderToResponseImpl (D:\next_auth\node_modules\next\dist\server\base-server.js:1899:32)
    at async DevServer.pipeImpl (D:\next_auth\node_modules\next\dist\server\base-server.js:912:25)
    at async NextNodeServer.handleCatchallRenderRequest (D:\next_auth\node_modules\next\dist\server\next-server.js:269:17)
    at async DevServer.handleRequestImpl (D:\next_auth\node_modules\next\dist\server\base-server.js:808:17)
    at async D:\next_auth\node_modules\next\dist\server\dev\next-dev-server.js:331:20
    at async Span.traceAsyncFn (D:\next_auth\node_modules\next\dist\trace\trace.js:151:20)       
    at async DevServer.handleRequest (D:\next_auth\node_modules\next\dist\server\dev\next-dev-server.js:328:24)
    at async invokeRender (D:\next_auth\node_modules\next\dist\server\lib\router-server.js:136:21)
    at async handleRequest (D:\next_auth\node_modules\next\dist\server\lib\router-server.js:315:24)
    at async requestHandlerImpl (D:\next_auth\node_modules\next\dist\server\lib\router-server.js:339:13)
    at async Server.requestListener (D:\next_auth\node_modules\next\dist\server\lib\start-server.js:140:13)
[auth][details]: {
  "provider": "google"
}

How to reproduce

# .env.local
AUTH_SECRET=dc123******

AUTH_GOOGLE_ID=89923******
AUTH_GOOGLE_SECRET=GOCSP*****
# auth.ts
import NextAuth from "next-auth"

import Google from "next-auth/providers/google"

import type { NextAuthConfig } from "next-auth"

export const config = {
  theme: {
    logo: "https://next-auth.js.org/img/logo/logo-sm.png",
  },
  providers: [
    Google,
  ],
  basePath: "/auth",
  callbacks: {
    authorized({ request, auth }) {
      const { pathname } = request.nextUrl
      if (pathname === "/middleware-example") return !!auth
      return true
    },
  },
} satisfies NextAuthConfig

export const { handlers, auth, signIn, signOut } = NextAuth(config)

Expected behavior

Google OAuth works fine as other providers do.

@BluSimmon BluSimmon added bug Something isn't working providers triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working providers triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant