Authorization

This part of the documentation covers the Authorization object.

class github3.auths.Authorization(auth, session=None)

The Authorization object.

Two authorization instances can be checked like so:

a1 == a2
a1 != a2

And is equivalent to:

a1.id == a2.id
a1.id != a2.id

See also: http://developer.github.com/v3/oauth/#oauth-authorizations-api

app = None

Details about the application (name, url)

created_at = None

datetime object representing when the authorization was created.

delete()

delete this authorization

from_json(json)

Return an instance of cls formed from json.

id = None

Unique id of the authorization

name = None

App name

note = None

Note about the authorization

note_url = None

URL about the note

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

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

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('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.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

scopes = None

List of scopes this applies to

to_json()

Return the json representing this object.

token = None

Returns the Authorization token

update(scopes=[], add_scopes=[], rm_scopes=[], note=u'', note_url=u'')

Update this authorization.

Parameters:
  • scopes (list) – (optional), replaces the authorization scopes with these
  • add_scopes (list) – (optional), scopes to be added
  • rm_scopes (list) – (optional), scopes to be removed
  • note (str) – (optional), new note about authorization
  • note_url (str) – (optional), new note URL about this authorization
Returns:

bool

updated_at = None

datetime object representing when the authorization was updated.