Skip to content

Commit 782482b

Browse files
feat: make tokens available in profile callback (nextauthjs#1329)
* 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
1 parent 2d364f2 commit 782482b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/server/lib/oauth/callback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async function getProfile ({ profileData, tokens, provider, user }) {
108108

109109
logger.debug('PROFILE_DATA', profileData)
110110

111-
const profile = await provider.profile(profileData)
111+
const profile = await provider.profile(profileData, tokens)
112112
// Return profile, raw profile and auth provider details
113113
return {
114114
profile: {

www/docs/configuration/providers.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ As an example of what this looks like, this is the the provider object returned
7878
requestTokenUrl: "https://accounts.google.com/o/oauth2/auth",
7979
authorizationUrl: "https://accounts.google.com/o/oauth2/auth?response_type=code",
8080
profileUrl: "https://www.googleapis.com/oauth2/v1/userinfo?alt=json",
81-
async profile(profile) {
81+
async profile(profile, tokens) {
82+
// You can use the tokens, in case you want to fetch more profile information
83+
// For example several OAuth provider does not return e-mail by default.
84+
// Depending on your provider, will have tokens like `access_token`, `id_token` and or `refresh_token`
8285
return {
8386
id: profile.id,
8487
name: profile.name,

0 commit comments

Comments
 (0)