oauth2.store.dbapi — PEP249 compatible stores

DBApi 2.0 (PEP249) compatible implementation of data stores.

class oauth2.store.dbapi.DatabaseStore(connection)[source]

Base class providing functionality used by a variety of store classes.

class oauth2.store.dbapi.DbApiAccessTokenStore(connection)[source]

Base class of a DBApi 2.0 compatible oauth2.store.AccessTokenStore.

A concrete implementation extends this class and defines all or a subset of the *_query class attributes.

create_access_token_query = None

Insert an access token.

create_data_query = None

Insert one entry of additional data associated with an access token.

create_scope_query = None

Insert one scope associated with an access token.

delete_refresh_token(refresh_token)[source]

Deletes an access token by its refresh token.

Parameters:refresh_token – The refresh token of an access token as a str.
delete_refresh_token_query = None

Delete an access token by its refresh token.

fetch_by_refresh_token(refresh_token)[source]

Retrieves an access token by its refresh token.

Parameters:refresh_token – The refresh token of an access token as a str.
Returns:An instance of oauth2.datatype.AccessToken.
Raises:oauth2.error.AccessTokenNotFound if not access token could be retrieved.
fetch_by_refresh_token_query = None

Retrieve an access token by its refresh token.

fetch_data_by_access_token_query = None

Retrieve all data associated with an access token.

fetch_existing_token_of_user(client_id, grant_type, user_id)[source]

Retrieve an access token issued to a client and user for a specific grant.

Parameters:
  • client_id – The identifier of a client as a str.
  • grant_type – The type of grant.
  • user_id – The identifier of the user the access token has been issued to.
Returns:

An instance of oauth2.datatype.AccessToken.

Raises:

oauth2.error.AccessTokenNotFound if not access token could be retrieved.

fetch_existing_token_of_user_query = None

Retrieve an access token issued to a client and user for a specific grant.

fetch_scopes_by_access_token_query = None

Retrieve all scopes associated with an access token.

save_token(access_token)[source]

Creates a new entry for an access token in the database.

Parameters:access_token – An instance of oauth2.datatype.AccessToken.
Returns:True.
class oauth2.store.dbapi.DbApiAuthCodeStore(connection)[source]

Base class of a DBApi 2.0 compatible oauth2.store.AuthCodeStore.

A concrete implementation extends this class and defines all or a subset of the *_query class attributes.

create_auth_code_query = None

Insert an auth code.

create_data_query = None

Insert one entry of additional data associated with an auth code.

create_scope_query = None

Insert one scope associated with an auth code.

delete_code(code)[source]

Delete an auth code identified by its code.

Parameters:code – The code of an auth code.
delete_code_query = None

Delete an auth code.

fetch_by_code(code)[source]

Retrieves an auth code by its code.

Parameters:code – The code of an auth code.
Returns:An instance of oauth2.datatype.AuthorizationCode.
Raises:oauth2.error.AuthCodeNotFound if no auth code could be retrieved.
fetch_code_query = None

Retrieve an auth code by its code.

fetch_data_query = None

Retrieve all data associated with an auth code.

fetch_scopes_query = None

Retrieve all scopes associated with an auth code.

save_code(authorization_code)[source]

Creates a new entry of an auth code in the database.

Parameters:authorization_code – An instance of oauth2.datatype.AuthorizationCode.
Returns:True if everything went fine.
class oauth2.store.dbapi.DbApiClientStore(connection)[source]

Base class of a DBApi 2.0 compatible oauth2.store.ClientStore.

A concrete implementation extends this class and defines all or a subset of the *_query class attributes.

fetch_by_client_id(client_id)[source]

Retrieves a client by its identifier.

Parameters:client_id – The identifier of a client.
Returns:An instance of oauth2.datatype.Client.
Raises:oauth2.error.ClientError if no client could be retrieved.
fetch_client_query = None

Retrieve a client by its identifier.

fetch_grants_query = None

Retrieve all grants that a client is allowed to use.

fetch_redirect_uris_query = None

Retrieve all redirect URIs of a client.

fetch_response_types_query = None

Retrieve all response types that a client supports.