Skip to content

Commit

Permalink
[pocketbase#405] updated Google OAuth2 userinfo response data
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Sep 9, 2022
1 parent a0d7f23 commit 96d09a3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tools/auth/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@ func NewGoogleProvider() *Google {

// FetchAuthUser returns an AuthUser instance based the Google's user api.
func (p *Google) FetchAuthUser(token *oauth2.Token) (*AuthUser, error) {
// https://cloud.google.com/identity-platform/docs/reference/rest/v1/UserInfo
rawData := struct {
LocalId string `json:"localId"`
DisplayName string `json:"displayName"`
Email string `json:"email"`
PhotoUrl string `json:"photoUrl"`
Id string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Picture string `json:"picture"`
}{}

if err := p.FetchRawUserData(token, &rawData); err != nil {
return nil, err
}

user := &AuthUser{
Id: rawData.LocalId,
Name: rawData.DisplayName,
Id: rawData.Id,
Name: rawData.Name,
Email: rawData.Email,
AvatarUrl: rawData.PhotoUrl,
AvatarUrl: rawData.Picture,
}

return user, nil
Expand Down

0 comments on commit 96d09a3

Please sign in to comment.