Next.js Discord

Discord Forum

Cannot read properties of undefined (reading 'sessionToken')

Answered
ncls. posted this in #help-forum
Open in Discord
Hello.

I wanted to set up OAuth2 with Twitch via NextAuth but when I try to authorize, it errors out saying "Try signing in with a different account" and the console shows this:
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read properties of undefined (reading 'sessionToken') {
  message: "Cannot read properties of undefined (reading 'sessionToken')",
  stack: "TypeError: Cannot read properties of undefined (reading 'sessionToken')\n" +
    '    at Object.callback (webpack-internal:///(rsc)/./node_modules/next-auth/core/routes/callback.js:106:40)\n' +
    '    at async AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:202:38)\n' +
    '    at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:50:30)\n' +
    '    at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:84:24)\n' +
    '    at async eval (webpack-internal:///(rsc)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:254:37)',
  name: 'TypeError'
}

Google does not have a single entry for that and I don't know what causes this or how to fix it.
Answered by ncls.
Solution: I forgot to add the database adapter to my NextAuth configuration.
View full answer

1 Reply

Solution: I forgot to add the database adapter to my NextAuth configuration.
Answer