session.accessToken is undefined · nextauthjs next-auth · Discussion #913 · GitHub
Skip to content

session.accessToken is undefined #913

Answered by balazsorban44
iamchathu asked this question in Help
Discussion options

You must be logged in to vote

@iamchathu

https://codesandbox.io/s/quizzical-wave-phrfj?file=/pages/api/auth/%5B...nextauth%5D.ts

Here is a working CodeSandbox for you. :)

The problem was that you did not check if account existed in jwt. I understood your intention with using optional chaining, but remember, it will just return undefined for account whenever jwt re-runs, resetting your accessToken you set in the first run.

I also added the accessToken to the session with the help of the session callback.

I created an Auth0 client and tested it, so I am sure it should work!

Replies: 6 comments 25 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@TheRealAstoo
Comment options

@balazsorban44
Comment options

@iamchathu
Comment options

@balazsorban44
Comment options

@iamchathu
Comment options

Comment options

You must be logged in to vote
13 replies
@iamchathu
Comment options

@balazsorban44
Comment options

@iamchathu
Comment options

@balazsorban44
Comment options

@DavidForDev
Comment options

Answer selected by balazsorban44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #913 on December 07, 2020 16:42.