-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make tokens available in profile callback #1329
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth-jemaoisjy/nextauthjs |
Hoping this gets merged! I hope this also clears the path for #955. Too much work for something so simple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was easy enough of a change! Haha
LGTM 👍
Sorry it's taken a few days to get round to this and thank you for tagging me! :-) Instead of passing a string as the second argument, I wonder if it's worth passing the entire IIRC, the I appreciate having type definitions here would be helpful and that the object format varies between providers makes it ambiguous what will be returned, but if we only return a specific key of Maybe we could then log a FIXME / TODO / or an issue to create and test better defined types with a range of providers to document them and see what they actually return? |
Thanks for the feedback! I can very easily send all the tokens as the second param, no problem. In v4, I would actually prefer if all our user facing apis could take a single object (aka named parameters) in case if they have more than one param. Easier to create types also. For now I can send the tokens and we see what we come up with later. |
🎉 This PR is included in version 3.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 4.1.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 4.0.0-next.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* feat: make access_token available in profile callback * docs(provider): mention access_token param in profile callback * feat: send all available tokens to provider.profile
What:
Adds a new parameter to the
profile()
callback in provider options.Why:
Since there is a lot of inconsistencies in OAuth provider implementations, the
profile
callback often provider an inconsistent result in its first parameter. Theprofile
callback is called asynchronously, so it is a good place to fetch more data, but usually, that request should be authenticated by the logged-in user. Without an access_token, it is in most cases probably impossible.How:
Forward
tokens
toprofile
, so it will receive these params:We will forward all the tokens we have for a provider. Depending on which provider we talk about, you will have an
access_token
,id_token
, andrefresh_token
.Checklist:
Discusses briefly: #1238 (comment)
Multiple of our built-in providers also return
null
for email and image because of this. With anaccess_token
available, it might be possible to fetch that info for those as well.