Next.js Discord

Discord Forum

Next-Auth token in URL issue

Unanswered
Dummi posted this in #help-forum
Open in Discord
Avatar
Whilst running the following code as provider in my project:
Discord({
    clientId: process.env.DiscordClientId as string,
    clientSecret: process.env.DiscordClientSecret as string,
    authorization: { params: { scope: 'identify email' } },
}),


I get the following error:

https://next-auth.js.org/errors#oauth_callback_error id_token detected in the response, you must use client.callback() instead of client.oauthCallback() {
  error: RPError: id_token detected in the response, you must use client.callback() instead of client.oauthCallback()
      at Client.oauthCallback (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:557:23)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async oAuthCallback (webpack-internal:///(rsc)/./node_modules/next-auth/core/lib/oauth/callback.js:96:16)
      at async Object.callback (webpack-internal:///(rsc)/./node_modules/next-auth/core/routes/callback.js:45:11)
      at async AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:175:28)
      at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:57:28)
      at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:89:16)
      at async D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:55038
      at async ek.execute (D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:45808)
      at async ek.handle (D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:56292)
      at async doRender (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1377:42)
      at async cacheEntry.responseCache.get.routeKind (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1587:40)
      at async DevServer.renderToResponseWithComponentsImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1507:28)
      at async DevServer.renderPageComponent (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1931:24)
      at async DevServer.renderToResponseImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1969:32)
      at async DevServer.pipeImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:920:25)
      at async NextNodeServer.handleCatchallRenderRequest (D:\apps\dummi.me\node_modules\next\dist\server\next-server.js:272:17)
      at async DevServer.handleRequestImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:816:17)
      at async D:\apps\dummi.me\node_modules\next\dist\server\dev\next-dev-server.js:339:20
      at async Span.traceAsyncFn (D:\apps\dummi.me\node_modules\next\dist\trace\trace.js:154:20)
      at async DevServer.handleRequest (D:\apps\dummi.me\node_modules\next\dist\server\dev\next-dev-server.js:336:24)
      at async invokeRender (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:174:21)
      at async handleRequest (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:353:24)
      at async requestHandlerImpl (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:377:13)
      at async Server.requestListener (D:\apps\dummi.me\node_modules\next\dist\server\lib\start-server.js:141:13) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'discord',
  message: 'id_token detected in the response, you must use client.callback() instead of client.oauthCallback()'
}


I can solve this error with adding idToken: true
Discord({
    clientId: process.env.DiscordClientId as string,
    clientSecret: process.env.DiscordClientSecret as string,
    authorization: { params: { scope: 'identify email' } },
    idToken: true,
}),


However this just creates another error:

3 Replies

Avatar
[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error unexpected iss value, expected undefined, got: https://discord.com {
  error: RPError: unexpected iss value, expected undefined, got: https://discord.com
      at Client.validateJWT (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:830:23)
      at Client.validateIdToken (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:664:64)
      at Client.callback (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:443:24)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async oAuthCallback (webpack-internal:///(rsc)/./node_modules/next-auth/core/lib/oauth/callback.js:94:16)
      at async Object.callback (webpack-internal:///(rsc)/./node_modules/next-auth/core/routes/callback.js:45:11)
      at async AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:175:28)
      at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:57:28)
      at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:89:16)
      at async D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:55038
      at async ek.execute (D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:45808)
      at async ek.handle (D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:56292)
      at async doRender (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1377:42)
      at async cacheEntry.responseCache.get.routeKind (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1587:40)
      at async DevServer.renderToResponseWithComponentsImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1507:28)
      at async DevServer.renderPageComponent (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1931:24)
      at async DevServer.renderToResponseImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1969:32)
      at async DevServer.pipeImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:920:25)
      at async NextNodeServer.handleCatchallRenderRequest (D:\apps\dummi.me\node_modules\next\dist\server\next-server.js:272:17)
      at async DevServer.handleRequestImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:816:17)
      at async D:\apps\dummi.me\node_modules\next\dist\server\dev\next-dev-server.js:339:20
      at async Span.traceAsyncFn (D:\apps\dummi.me\node_modules\next\dist\trace\trace.js:154:20)
      at async DevServer.handleRequest (D:\apps\dummi.me\node_modules\next\dist\server\dev\next-dev-server.js:336:24)
      at async invokeRender (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:174:21)
      at async handleRequest (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:353:24)
      at async requestHandlerImpl (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:377:13)
      at async Server.requestListener (D:\apps\dummi.me\node_modules\next\dist\server\lib\start-server.js:141:13) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'discord',
  message: 'unexpected iss value, expected undefined, got: https://discord.com'
}
solution: issuer: 'http://localhost:3000'

Discord({
    clientId: process.env.DiscordClientId as string,
    clientSecret: process.env.DiscordClientSecret as string,
    authorization: { params: { scope: 'identify email' } },
    issuer: 'https://discord.com',
    idToken: true,
})

creates the next error

[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error jwks_uri must be configured on the issuer {
  error: TypeError: jwks_uri must be configured on the issuer
      at assertIssuerConfiguration (webpack-internal:///(rsc)/./node_modules/openid-client/lib/helpers/assert.js:17:11)
      at Issuer.getKeyStore (webpack-internal:///(rsc)/./node_modules/openid-client/lib/helpers/issuer.js:22:3)
      at Issuer.queryKeyStore (webpack-internal:///(rsc)/./node_modules/openid-client/lib/helpers/issuer.js:84:38)
      at Client.validateJWT (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:976:40)
      at Client.validateIdToken (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:664:64)
      at Client.callback (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:443:24)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async oAuthCallback (webpack-internal:///(rsc)/./node_modules/next-auth/core/lib/oauth/callback.js:94:16)
      at async Object.callback (webpack-internal:///(rsc)/./node_modules/next-auth/core/routes/callback.js:45:11)
      at async AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:175:28)
      at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:57:28)
      at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:89:16)
      at async D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:55038
      at async ek.execute (D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:45808)
      at async ek.handle (D:\apps\dummi.me\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:56292)
      at async doRender (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1377:42)
      at async cacheEntry.responseCache.get.routeKind (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1587:40)
      at async DevServer.renderToResponseWithComponentsImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1507:28)
      at async DevServer.renderPageComponent (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1931:24)
      at async DevServer.renderToResponseImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:1969:32)
      at async DevServer.pipeImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:920:25)
      at async NextNodeServer.handleCatchallRenderRequest (D:\apps\dummi.me\node_modules\next\dist\server\next-server.js:272:17)
      at async DevServer.handleRequestImpl (D:\apps\dummi.me\node_modules\next\dist\server\base-server.js:816:17)
      at async D:\apps\dummi.me\node_modules\next\dist\server\dev\next-dev-server.js:339:20
      at async Span.traceAsyncFn (D:\apps\dummi.me\node_modules\next\dist\trace\trace.js:154:20)
      at async DevServer.handleRequest (D:\apps\dummi.me\node_modules\next\dist\server\dev\next-dev-server.js:336:24)
      at async invokeRender (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:174:21)
      at async handleRequest (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:353:24)
      at async requestHandlerImpl (D:\apps\dummi.me\node_modules\next\dist\server\lib\router-server.js:377:13)
      at async Server.requestListener (D:\apps\dummi.me\node_modules\next\dist\server\lib\start-server.js:141:13) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'discord',
  message: 'jwks_uri must be configured on the issuer'
}
solution to this? setting the jwks_uri ofcourse!

I don't know what this uri is supposed to point to, or maybe there is no need for any jwks stuff with a different provider setup (that would be ideal)