Authorization¶
This part of the documentation covers the
Authorization
object.
-
class
github3.auths.
Authorization
(json, session)¶ Representation of an OAuth Authorization.
See also: https://developer.github.com/v3/oauth_authorizations/
This object has the following attributes:
-
app
¶ Details about the application the authorization was created for.
-
created_at
¶ A
datetime
representing when this authorization was created.
-
fingerprint
¶ New in version 1.0.
The optional parameter that is used to allow an OAuth application to create multiple authorizations for the same user. This will help distinguish two authorizations for the same app.
-
hashed_token
¶ New in version 1.0.
This is the base64 of the SHA-256 digest of the token.
See also
- Removing Authorization Tokens
- The blog post announcing the removal of
token
.
-
id
¶ The unique identifier for this authorization.
-
note_url
¶ The URL that points to a longer description about the purpose of this autohrization.
-
note
¶ The short note provided when this authorization was created.
-
scopes
¶ The list of scopes assigned to this token.
See also
- Scopes for OAuth Applications
- GitHub’s documentation around available scopes and what they mean
-
token
¶ If this authorization was created, this will contain the full token. Otherwise, this attribute will be an empty string.
-
token_last_eight
¶ New in version 1.0.
The last eight characters of the token. This allows users to identify a token after the initial retrieval.
-
updated_at
¶ A
datetime
representing when this authorization was most recently updated.
-
add_scopes
(scopes, note=None, note_url=None)¶ Add the scopes to this authorization.
New in version 1.0.
Parameters: - scopes (list) – Adds these scopes to the ones present on this authorization
- note (str) – (optional), Note about the authorization
- note_url (str) – (optional), URL to link to when the user views the authorization
Returns: True if successful, False otherwise
Return type: bool
-
as_dict
()¶ Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
Returns: this object’s attributes serialized to a dictionary Return type: dict
-
as_json
()¶ Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
Returns: this object’s attributes as a JSON string Return type: str
-
delete
()¶ Delete this authorization.
Returns: True if successful, False otherwise Return type: bool
-
from_dict
(json_dict, session)¶ Return an instance of this class formed from
json_dict
.
-
from_json
(json, session)¶ Return an instance of this class formed from
json
.
-
new_session
()¶ Generate a new session.
Returns: A brand new session Return type: GitHubSession
-
ratelimit_remaining
¶ Number of requests before GitHub imposes a ratelimit.
Returns: int
-
refresh
(conditional=False)¶ Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos = [r.refresh() for r in g.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and you would otherwise have to do:repos = [r for i in g.repositories_by('kennethreitz')] [r.refresh() for r in repos]
Which is really an anti-pattern.
Changed in version 0.5.
Parameters: conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs Returns: self
-
remove_scopes
(scopes, note=None, note_url=None)¶ Remove the scopes from this authorization.
New in version 1.0.
Parameters: - scopes (list) – Remove these scopes from the ones present on this authorization
- note (str) – (optional), Note about the authorization
- note_url (str) – (optional), URL to link to when the user views the authorization
Returns: True if successful, False otherwise
Return type: bool
-
replace_scopes
(scopes, note=None, note_url=None)¶ Replace the scopes on this authorization.
New in version 1.0.
Parameters: - scopes (list) – Use these scopes instead of the previous list
- note (str) – (optional), Note about the authorization
- note_url (str) – (optional), URL to link to when the user views the authorization
Returns: True if successful, False otherwise
Return type: bool
-