oauth2
— Provider Class¶
-
class
oauth2.
Provider
(access_token_store, auth_code_store, client_store, token_generator, client_authentication_source=<function request_body>, response_class=<class 'oauth2.web.Response'>)[source]¶ Endpoint of requests to the OAuth 2.0 provider.
Parameters: - access_token_store (oauth2.store.AccessTokenStore) – An object that implements methods defined
by
oauth2.store.AccessTokenStore
. - auth_code_store (oauth2.store.AuthCodeStore) – An object that implements methods defined by
oauth2.store.AuthCodeStore
. - client_store (oauth2.store.ClientStore) – An object that implements methods defined by
oauth2.store.ClientStore
. - token_generator (oauth2.tokengenerator.TokenGenerator) – Object to generate unique tokens.
- client_authentication_source (callable) – A callable which when executed,
authenticates a client.
See
oauth2.client_authenticator
. - response_class (oauth2.web.Response) – Class of the response object.
Defaults to
oauth2.web.Response
.
Changed in version 1.0.0: Removed parameter
site_adapter
.-
add_grant
(grant)[source]¶ Adds a Grant that the provider should support.
Parameters: grant (oauth2.grant.GrantHandlerFactory) – An instance of a class that extends oauth2.grant.GrantHandlerFactory
-
dispatch
(request, environ)[source]¶ Checks which Grant supports the current request and dispatches to it.
Parameters: - request (
oauth2.web.Request
) – The incoming request. - environ (dict) – Dict containing variables of the environment.
Returns: An instance of
oauth2.web.Response
.- request (
-
enable_unique_tokens
()[source]¶ Enable the use of unique access tokens on all grant types that support this option.
-
scope_separator
¶ Sets the separator of values in the scope query parameter. Defaults to ” ” (whitespace).
The following code makes the Provider use “,” instead of ” “:
provider = Provider() provider.scope_separator = ","
Now the scope parameter in the request of a client can look like this: scope=foo,bar.
- access_token_store (oauth2.store.AccessTokenStore) – An object that implements methods defined
by