diff --git a/src/server/lib/oauth/callback.js b/src/server/lib/oauth/callback.js index d52781a7dd..c33fcc7d62 100644 --- a/src/server/lib/oauth/callback.js +++ b/src/server/lib/oauth/callback.js @@ -108,7 +108,7 @@ async function getProfile ({ profileData, tokens, provider, user }) { logger.debug('PROFILE_DATA', profileData) - const profile = await provider.profile(profileData) + const profile = await provider.profile(profileData, tokens) // Return profile, raw profile and auth provider details return { profile: { diff --git a/www/docs/configuration/providers.md b/www/docs/configuration/providers.md index 5ea670da29..db651d4fc1 100644 --- a/www/docs/configuration/providers.md +++ b/www/docs/configuration/providers.md @@ -78,7 +78,10 @@ As an example of what this looks like, this is the the provider object returned requestTokenUrl: "https://accounts.google.com/o/oauth2/auth", authorizationUrl: "https://accounts.google.com/o/oauth2/auth?response_type=code", profileUrl: "https://www.googleapis.com/oauth2/v1/userinfo?alt=json", - async profile(profile) { + async profile(profile, tokens) { + // You can use the tokens, in case you want to fetch more profile information + // For example several OAuth provider does not return e-mail by default. + // Depending on your provider, will have tokens like `access_token`, `id_token` and or `refresh_token` return { id: profile.id, name: profile.name,