Configuration¶
Flask-Dance provides many options for configuring how the OAuth process works.
-
OAuth2ConsumerBlueprint.__init__(name, import_name, client_id=None, client_secret=None, client=None, auto_refresh_url=None, auto_refresh_kwargs=None, scope=None, state=None, static_folder=None, static_url_path=None, template_folder=None, url_prefix=None, subdomain=None, url_defaults=None, root_path=None, login_url=None, authorized_url=None, base_url=None, authorization_url=None, authorization_url_params=None, token_url=None, token_url_params=None, redirect_url=None, redirect_to=None, session_class=None, backend=None, **kwargs)[source]¶ Most of the constructor arguments are forwarded either to the
flask.Blueprintconstructor or therequests_oauthlib.OAuth2Sessionconstructor, including**kwargs(which is forwarded toOAuth2Session). Only the arguments that are relevant to Flask-Dance are documented here.Parameters: - base_url – The base URL of the OAuth provider. If specified, all URLs passed to this instance will be resolved relative to this URL.
- authorization_url – The URL specified by the OAuth provider for
obtaining an
authorization grant.
This can be an fully-qualified URL, or a path that is
resolved relative to the
base_url. - authorization_url_params (dict) – A dict of extra
key-value pairs to include in the query string of the
authorization_url, beyond those necessary for a standard OAuth 2 authorization grant request. - token_url – The URL specified by the OAuth provider for
obtaining an
access token.
This can be an fully-qualified URL, or a path that is
resolved relative to the
base_url. - token_url_params (dict) – A dict of extra
key-value pairs to include in the query string of the
token_url, beyond those necessary for a standard OAuth 2 access token request. - login_url – The URL route for the
loginview that kicks off the OAuth dance. This string will be formatted with the instance so that attributes can be interpolated. Defaults to/{bp.name}, so that the URL is based on the name of the blueprint. - authorized_url – The URL route for the
authorizedview that completes the OAuth dance. This string will be formatted with the instance so that attributes can be interpolated. Defaults to/{bp.name}/authorized, so that the URL is based on the name of the blueprint. - redirect_url – When the OAuth dance is complete, redirect the user to this URL.
- redirect_to – When the OAuth dance is complete,
redirect the user to the URL obtained by calling
url_for()with this argument. If you do not specify eitherredirect_urlorredirect_to, the user will be redirected to the root path (/). - session_class – The class to use for creating a Requests session
between the consumer (your website) and the provider (e.g.
Twitter). Defaults to
OAuth2Session. - backend – A storage backend class, or an instance of a storage
backend class, to use for this blueprint. Defaults to
SessionBackend.