Skip to content

Commit

Permalink
Merge pull request #272 from lukashes/master
Browse files Browse the repository at this point in the history
Do not use user_ids field in VK provider
  • Loading branch information
bentranter authored Mar 26, 2019
2 parents 7baf284 + 34aa31c commit 55fc853
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions providers/vk/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Session struct {
AuthURL string
AccessToken string
ExpiresAt time.Time
userID int64
email string
}

Expand Down Expand Up @@ -49,15 +48,9 @@ func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string,
return "", errors.New("Cannot fetch user email")
}

userID, ok := token.Extra("user_id").(float64)
if !ok {
return "", errors.New("Cannot fetch user ID")
}

s.AccessToken = token.AccessToken
s.ExpiresAt = token.Expiry
s.email = email
s.userID = int64(userID)
return s.AccessToken, err
}

Expand Down
2 changes: 1 addition & 1 deletion providers/vk/vk.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
}

fields := "photo_200,nickname"
requestURL := fmt.Sprintf("%s?user_ids=%d&fields=%s&access_token=%s&v=%s", endpointUser, sess.userID, fields, sess.AccessToken, apiVersion)
requestURL := fmt.Sprintf("%s?fields=%s&access_token=%s&v=%s", endpointUser, fields, sess.AccessToken, apiVersion)
response, err := p.Client().Get(requestURL)
if err != nil {
return user, err
Expand Down

0 comments on commit 55fc853

Please sign in to comment.