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:

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.

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.