Skip to content

Commit

Permalink
Add IDToken for google provider
Browse files Browse the repository at this point in the history
  • Loading branch information
wgjak47 committed Aug 4, 2021
1 parent 153d389 commit 363f56f
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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 @@ -139,9 +140,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
Original file line number Diff line number Diff line change
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 363f56f

Please sign in to comment.