oauth2.store.memory — In-memory store adapters

Read or write data from or to local memory.

Though not very valuable in a production setup, these store adapters are great for testing purposes.

class oauth2.store.memory.ClientStore[source]

Stores clients in memory.

add_client(client_id, client_secret, redirect_uris)[source]

Add a client app.

Parameters:
  • client_id – Identifier of the client app.
  • client_secret – Secret the client app uses for authentication against the OAuth 2.0 provider.
  • redirect_uris – A list of URIs to redirect to.
fetch_by_client_id(client_id)[source]

Retrieve a client by its identifier.

Parameters:client_id – Identifier of a client app.
Returns:An instance of oauth2.Client.
Raises:ClientNotFoundError
class oauth2.store.memory.TokenStore[source]

Stores tokens in memory.

Useful for testing purposes or APIs with a very limited set of clients. Use memcache or redis as storage to be able to scale.

fetch_by_code(code)[source]

Returns an AuthorizationCode.

Parameters:code – The authorization code.
Returns:An instance of oauth2.datatype.AuthorizationCode.
Raises:AuthCodeNotFound if no data could be retrieved for given code.
fetch_by_refresh_token(refresh_token)[source]

Find an access token by its refresh token.

Parameters:refresh_token – The refresh token that was assigned to an AccessToken.
Returns:The oauth2.datatype.AccessToken.
Raises:oauth2.error.AccessTokenNotFound
fetch_by_token(token)[source]

Returns data associated with an access token or None if no data was found.

Useful for cases like validation where the access token needs to be read again.

Parameters:token – A access token code.
Returns:An instance of oauth2.datatype.AccessToken.
save_code(authorization_code)[source]

Stores the data belonging to an authorization code token.

Parameters:authorization_code – An instance of oauth2.datatype.AuthorizationCode.
save_token(access_token)[source]

Stores an access token and additional data in memory.

Parameters:access_token – An instance of oauth2.datatype.AccessToken.