Skip to content
Snippets Groups Projects
Commit 3920970c authored by Ian Cordasco's avatar Ian Cordasco
Browse files

Decode the hashed token conditionally

Start accepting the fingerprint parameter for GitHub#authorize and
alias GitHub#authorize to GitHub#create_authorization
parent edc7f6db
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -59,7 +59,9 @@ class Authorization(models.GitHubCore):
#: base64-encoded of the SHA-256 digest of the token
self.hashed_token = auth.get('hashed_token')
#: SHA-256 digest of the token (derived from ``hashed_token``)
self.sha256_hashed_token = base64.b64decode(self.hashed_token)
self.sha256_hashed_token = None
if self.hashed_token:
self.sha256_hashed_token = base64.b64decode(self.hashed_token)
#: A string that distinguishes the new authorization from others for
#: the same client ID and user
self.fingerprint = auth.get('fingerprint')
Loading
Loading
Loading
Loading
@@ -144,7 +144,7 @@ class GitHub(GitHubCore):
return self._iter(int(number), url, Authorization, etag=etag)
 
def authorize(self, username, password, scopes=None, note='', note_url='',
client_id='', client_secret=''):
client_id='', client_secret='', fingerprint=''):
"""Obtain an authorization token.
 
The retrieved token will allow future consumers to use the API without
Loading
Loading
@@ -170,12 +170,16 @@ class GitHub(GitHubCore):
'client_id': client_id, 'client_secret': client_secret}
if scopes:
data['scopes'] = scopes
if fingerprint:
data['fingerprint'] = fingerprint
 
with self.session.temporary_basic_auth(username, password):
json = self._json(self._post(url, data=data), 201)
 
return self._instance_or_null(Authorization, json)
 
create_authorization = authorize
def check_authorization(self, access_token):
"""Check an authorization created by a registered application.
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment