8
8
"""
9
9
from __future__ import unicode_literals
10
10
11
- from .decorators import requires_basic_auth
12
- from .models import GitHubCore
11
+ import base64
13
12
13
+ from . import decorators
14
+ from . import models
14
15
15
- class Authorization (GitHubCore ):
16
+
17
+ class Authorization (models .GitHubCore ):
16
18
17
19
"""T
8000
he :class:`Authorization <Authorization>` object.
18
20
@@ -30,11 +32,13 @@ class Authorization(GitHubCore):
30
32
31
33
"""
32
34
35
+ CUSTOM_HEADERS = {'Accept' : 'application/vnd.github.mirage-preview+json' }
36
+
33
37
def _update_attributes (self , auth ):
34
38
self ._api = auth .get ('url' )
35
39
#: Details about the application (name, url)
36
40
self .app = auth .get ('app' , {})
37
- #: Returns the Authorization token
41
+ #: **DEPRECATED** Returns the Authorization token
38
42
self .token = auth .get ('token' , '' )
39
43
#: App name
40
44
self .name = self .app .get ('name' , '' )
@@ -50,6 +54,15 @@ def _update_attributes(self, auth):
50
54
self .created_at = self ._strptime (auth .get ('created_at' ))
51
55
#: datetime object representing when the authorization was updated.
52
56
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' )
53
66
54
67
def _repr (self ):
55
68
return '<Authorization [{0}]>' .format (self .name )
@@ -68,7 +81,7 @@ def _update(self, scopes_data, note, note_url):
68
81
69
82
return False
70
83
71
- @requires_basic_auth
84
+ @decorators . requires_basic_auth
72
85
def add_scopes (self , scopes , note = None , note_url = None ):
73
86
"""Remove the scopes from this authorization.
74
87
@@ -84,12 +97,12 @@ def add_scopes(self, scopes, note=None, note_url=None):
84
97
"""
85
98
return self ._update ({'add_scopes' : scopes }, note , note_url )
86
99
87
- @requires_basic_auth
100
+ @decorators . requires_basic_auth
88
101
def delete (self ):
89
102
"""Delete this authorization."""
90
103
return self ._boolean (self ._delete (self ._api ), 204 , 404 )
91
104
92
- @requires_basic_auth
105
+ @decorators . requires_basic_auth
93
106
def remove_scopes (self , scopes , note = None , note_url = None ):
94
107
"""Remove the scopes from this authorization.
95
108
@@ -105,7 +118,7 @@ def remove_scopes(self, scopes, note=None, note_url=None):
105
118
"""
106
119
return self ._update ({'rm_scopes' : scopes }, note , note_url )
107
120
108
- @requires_basic_auth
121
+ @decorators . requires_basic_auth
109
122
def replace_scopes (self , scopes , note = None , note_url = None ):
110
123
"""Replace the scopes on this authorization.
111
124
0 commit comments