Skip to content

Commit

Permalink
Merge pull request #417 from wgjak47/master
Browse files Browse the repository at this point in the history
Add IDToken for google provider
  • Loading branch information
bentranter committed Oct 5, 2021
2 parents 47326a3 + 363f56f commit 90149bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions providers/google/google.go
Expand Up @@ -92,6 +92,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
Provider: p.Name(),
RefreshToken: sess.RefreshToken,
ExpiresAt: sess.ExpiresAt,
IDToken: sess.IDToken,
}

if user.AccessToken == "" {
Expand Down Expand Up @@ -145,9 +146,7 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {
}

if len(scopes) > 0 {
for _, scope := range scopes {
c.Scopes = append(c.Scopes, scope)
}
c.Scopes = append(c.Scopes, scopes...)
} else {
c.Scopes = []string{"email"}
}
Expand Down
2 changes: 2 additions & 0 deletions providers/google/session.go
Expand Up @@ -15,6 +15,7 @@ type Session struct {
AccessToken string
RefreshToken string
ExpiresAt time.Time
IDToken string
}

// GetAuthURL will return the URL set by calling the `BeginAuth` function on the Google provider.
Expand All @@ -40,6 +41,7 @@ func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string,
s.AccessToken = token.AccessToken
s.RefreshToken = token.RefreshToken
s.ExpiresAt = token.Expiry
s.IDToken = token.Extra("id_token").(string)
return token.AccessToken, err
}

Expand Down

0 comments on commit 90149bc

Please sign in to comment.