10000 Add new attributes from the experimental API · borgstrom/github3.py@edc7f6d · GitHub
[go: up one dir, main page]

Skip to content

Commit edc7f6d

Browse files
committed
Add new attributes from the experimental API
1 parent 1271a48 commit edc7f6d

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

github3/auths.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
"""
99
from __future__ import unicode_literals
1010

11-
from .decorators import requires_basic_auth
12-
from .models import GitHubCore
11+
import base64
1312

13+
from . import decorators
14+
from . import models
1415

15-
class Authorization(GitHubCore):
16+
17+
class Authorization(models.GitHubCore):
1618

1719
"""T 8000 he :class:`Authorization <Authorization>` object.
1820
@@ -30,11 +32,13 @@ class Authorization(GitHubCore):
3032
3133
"""
3234

35+
CUSTOM_HEADERS = {'Accept': 'application/vnd.github.mirage-preview+json'}
36+
3337
def _update_attributes(self, auth):
3438
self._api = auth.get('url')
3539
#: Details about the application (name, url)
3640
self.app = auth.get('app', {})
37-
#: Returns the Authorization token
41+
#: **DEPRECATED** Returns the Authorization token
3842
self.token = auth.get('token', '')
3943
#: App name
4044
self.name = self.app.get('name', '')
@@ -50,6 +54,15 @@ def _update_attributes(self, auth):
5054
self.created_at = self._strptime(auth.get('created_at'))
5155
#: datetime object representing when the authorization was updated.
5256
self.updated_at = self._strptime(auth.get('updated_at'))
57+
#: Last eight characters of the associated OAuth token
58+
self.token_last_eight = auth.get('token_last_eight')
59+ 8000
#: base64-encoded of the SHA-256 digest of the token
60+
self.hashed_token = auth.get('hashed_token')
61+
#: SHA-256 digest of the token (derived from ``hashed_token``)
62+
self.sha256_hashed_token = base64.b64decode(self.hashed_token)
63+
#: A string that distinguishes the new authorization from others for
64+
#: the same client ID and user
65+
self.fingerprint = auth.get('fingerprint')
5366

5467
def _repr(self):
5568
return '<Authorization [{0}]>'.format(self.name)
@@ -68,7 +81,7 @@ def _update(self, scopes_data, note, note_url):
6881

6982
return False
7083

71-
@requires_basic_auth
84+
@decorators.requires_basic_auth
7285
def add_scopes(self, scopes, note=None, note_url=None):
7386
"""Remove the scopes from this authorization.
7487
@@ -84,12 +97,12 @@ def add_scopes(self, scopes, note=None, note_url=None):
8497
"""
8598
return self._update({'add_scopes': scopes}, note, note_url)
8699

87-
@requires_basic_auth
100+
@decorators.requires_basic_auth
88101
def delete(self):
89102
"""Delete this authorization."""
90103
return self._boolean(self._delete(self._api), 204, 404)
91104

92-
@requires_basic_auth
105+
@decorators.requires_basic_auth
93106
def remove_scopes(self, scopes, note=None, note_url=None):
94107
"""Remove the scopes from this authorization.
95108
@@ -105,7 +118,7 @@ def remove_scopes(self, scopes, note=None, note_url=None):
105118
"""
106119
return self._update({'rm_scopes': scopes}, note, note_url)
107120

108-
@requires_basic_auth
121+
@decorators.requires_basic_auth
109122
def replace_scopes(self, scopes, note=None, note_url=None):
110123
"""Replace the scopes on this authorization.
111124

0 commit comments

Comments
 (0)
0