I am following this tutorial & am unable to get the value of access_token
& refresh_token
from next-auth. My callback function looks like:
callbacks: {
async jwt({ token, account, user }) {
if (account) {
token[account.provider] = {
accessToken: account.access_token,
refreshToken: account.refresh_token,
}
console.log(token[account.provider])
}
return token
},
},
It currently logs { accessToken: undefined, refreshToken: undefined }
to the console.
This is how it's shown in the docs when using jwt callbacks but it's not working for me.
I have made a complete reproduction on branch next-auth-with-twitter-api-v2
→ https://github.com/deadcoder0904/twitter-api-v2-3-legged-login-using-next-connect/tree/next-auth-with-twitter-api-v2
It looks like it works on v3. See branch next-auth-v3-with-twitter-api-v2
→ https://github.com/deadcoder0904/twitter-api-v2-3-legged-login-using-next-connect/tree/next-auth-v3-with-twitter-api-v2
So the access_token
got renamed to oauth_token
& refresh_token
got renamed to oauth_token_secret
:
callbacks: {
async jwt({ token, account, user }) {
if (account) {
token[account.provider] = {
accessToken: account.oauth_token,
refreshToken: account.oauth_token_secret,
}
}
return token
},
},