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, authorized_grants=None, authorized_response_types=None)[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.
-
-
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.
-
delete_code
(code)[source]¶ Deletes an authorization code after use :param code: The authorization code.
-
delete_refresh_token
(refresh_token)[source]¶ Deletes a refresh token after use :param refresh_token: The refresh_token.
-
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
.
-
fetch_existing_token_of_user
(client_id, grant_type, user_id)[source]¶ Fetches an access token identified by its client id, type of grant and user id.
This method must be implemented to make use of unique access tokens.
Parameters: - client_id – Identifier of the client a token belongs to.
- grant_type – The type of the grant that created the token
- user_id – Identifier of the user a token belongs to.
Returns: An instance of
oauth2.datatype.AccessToken
.Raises: oauth2.error.AccessTokenNotFound
if no data could be retrieved.
-
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
.
-