Credentials provider and jwt/session callbacks #4453
Unanswered
olivier-thatch
asked this question in
Help
Replies: 1 comment 3 replies
-
I was able to make it work by using the callbacks: {
async signIn({ user, account }) {
account.access_token = user.access_token
return true
},
async jwt({ token, account }) {
if (account) {
token.accessToken = account.access_token
}
return token
},
async session({ session, token, user }) {
session.accessToken = token.accessToken
return session
}
}, This doesn't really seem like an appropriate use of the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm trying to use next-auth with the credentials provider to authenticate with an API. The response from the API login endpoint includes an access token that I want to persist in the JWT and session to be used in further API calls.
However, I cannot seem to access the original response in the
jwt
andsession
callbacks.My code looks like this:
The
token
returned by the API's login endpoint looks like this:and the callbacks are basically exactly the same as the ones in the documentation. However the code is not working: in the
jwt
callback, theaccount
argument is not the response from the API, rather it looks like this:I cannot seem to figure out how to access the API response from the
jwt
callback. Any help would be much appreciated!Beta Was this translation helpful? Give feedback.
All reactions