geofront.backends.oauth — Team backend bases for OAuth

New in version 0.4.0.

class geofront.backends.oauth.OAuth2Team(client_id: str, client_secret: str) → None

Base implementation of Team for OAuth 2. Every subclass has to implement the following attributes and methods:

access_token_url = NotImplemented

(str) The url to issue an OAuth 2 access token.

Note

Concrete subclass has to implement this method.

authorize_scope = NotImplemented

(str) The scope string for OAuth 2 authorization.

Note

Concrete subclass has to implement this method.

authorize_url = NotImplemented

(str) The OAuth 2 authorization url.

Note

Concrete subclass has to implement this method.

determine_identity(access_token: str) → geofront.identity.Identity

Determine Identity from the given access token.

Note

Concrete subclass has to implement this method.

unauthorized_identity_message_format = 'identity {identity} is unauthorized'

(str) The message template which is used when the authenticated identity is unauthorized. There’s a predefined default message, but it can be overridden by subclass. The two keywords are available:

identity
(Identity) The authenticated identity.
team
(OAuth2Team) The actual team object.
geofront.backends.oauth.request(access_token, url: str, method: str = 'GET', data: bytes = None)

Make a request to GitHub API, and then return the parsed JSON result.

Parameters:
  • access_token (str, Identity) – api access token string, or Identity instance
  • url (str) – the api url to request
  • method (str) – an optional http method. 'GET' by default
  • data (bytes) – an optional content body