Next.js Discord

Discord Forum

When using the credentials provider, what is the correct way to get the accessToken for the headers?

Unanswered
Egyptian Mau posted this in #help-forum
Open in Discord
Egyptian MauOP
I am using the credentials provider with a node backend that authenticates based on a jwt token. What I am doing right now is that I set the accessToken on the user object in my authorize() function and return it.

In the jwt callback I then write the accessToken from user to the token.

In the session callback I then assign the accessToken from token to the session.

Now during my request I would call getServerSession() and use the accessToken, is this the intended way and more importantly is this secure?

1 Reply

could you share your code for the setting of access token please. I am facing same problem. I don't understand how to fetch the access Token from a Credentials login