Skip to content
Prev Previous commit
Next Next commit
Fix github.com login deprecated GET Access
  • Loading branch information
katzlbt committed Nov 19, 2021
commit 353a8f8ccdbf6c7ca4d3f60938f64aad1bc9d9c5
18 changes: 8 additions & 10 deletions velruse/providers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,20 @@ def callback(self, request):
provider_type=self.type)

# Now retrieve the access token with the code
access_url = flat_url(
'%s://%s/login/oauth/access_token' % (self.protocol, self.domain),
client_id=self.consumer_key,
client_secret=self.consumer_secret,
redirect_uri=request.route_url(self.callback_route),
code=code)
r = requests.get(access_url)
access_url = flat_url('%s://%s/login/oauth/access_token' % (self.protocol, self.domain))
payload = { "client_id": self.consumer_key,
"client_secret": self.consumer_secret,
"redirect_uri": request.route_url(self.callback_route),
"code": code}
r = requests.post(access_url, data=payload)
if r.status_code != 200:
raise ThirdPartyFailure("Status %s: %s" % (
r.status_code, r.content))
access_token = dict(parse_qsl(r.text))['access_token']

# Retrieve profile data
graph_url = flat_url('%s://api.%s/user' % (self.protocol, self.domain),
access_token=access_token)
graph_headers = dict(Accept='application/vnd.github.v3+json')
graph_url = flat_url('%s://api.%s/user' % (self.protocol, self.domain))
graph_headers = { "Accept":'application/vnd.github.v3+json', "Authorization": "token " + access_token}
r = requests.get(graph_url, headers=graph_headers)
if r.status_code != 200:
raise ThirdPartyFailure("Status %s: %s" % (
Expand Down