Skip to content

Commit

Permalink
Merge pull request #428 from asherf/github
Browse files Browse the repository at this point in the history
[Github] Pass access token in a header.
  • Loading branch information
omab authored Mar 15, 2020
2 parents c8d172e + 3818924 commit bc79fd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Use `unidecode` to cleanup usernames from unicode characters
- Update Twitch API support from v3 to v5
- Properly setup `pytest` version for Python2 and Python3
- Github: pass access token in a header instead of in a query parameter.

## [3.2.0](https://github.com/python-social-auth/social-core/releases/tag/3.2.0) - 2019-05-30

Expand Down
7 changes: 3 additions & 4 deletions social_core/backends/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def user_data(self, access_token, *args, **kwargs):

def _user_data(self, access_token, path=None):
url = urljoin(self.api_url(), 'user{0}'.format(path or ''))
return self.get_json(url, params={'access_token': access_token})
return self.get_json(url, headers={'Authorization': 'token {0}'.format(access_token)})


class GithubMemberOAuth2(GithubOAuth2):
Expand All @@ -76,10 +76,9 @@ def user_data(self, access_token, *args, **kwargs):
user_data = super(GithubMemberOAuth2, self).user_data(
access_token, *args, **kwargs
)
headers = {'Authorization': 'token {0}'.format(access_token)}
try:
self.request(self.member_url(user_data), params={
'access_token': access_token
})
self.request(self.member_url(user_data), headers=headers)
except HTTPError as err:
# if the user is a member of the organization, response code
# will be 204, see http://bit.ly/ZS6vFl
Expand Down

0 comments on commit bc79fd4

Please sign in to comment.