Skip to content

Add attributes to user during authorization #764

Answered by dimbslmh
danjamesmedia asked this question in Help
Discussion options

You must be logged in to vote

I was having the same issue, but it has been documented here https://next-auth.js.org/configuration/callbacks#session-callback:

When using JSON Web Tokens for sessions, the JWT payload is provided instead.

Tip

When using JSON Web Tokens the jwt() callback is invoked before the session() callback, so anything you add to the JSON Web Token will be immediately available in the session callback.

Tip

To better represent its value, when using a JWT session, the second parameter should be called token (This is the same thing you return from the jwt() callback). ...

In the jwt callback you can add attributes from the user object to the token object that you want to have during the session c…

Replies: 3 comments 19 replies

Comment options

You must be logged in to vote
11 replies
@jackzbazuka
Comment options

@balazsorban44
Comment options

@raulmarindev
Comment options

@ogooluwanick
Comment options

@derekgygax
Comment options

Answer selected by balazsorban44
Comment options

You must be logged in to vote
8 replies
@baptisteArno
Comment options

@balazsorban44
Comment options

@nemanjam
Comment options

@balazsorban44
Comment options

@phongvuhyuet
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
Converted from issue

This discussion was converted from issue #764 on December 09, 2020 00:41.