Pre-set Configurations

Flask-Dance comes with pre-set OAuth consumer configurations for a few popular OAuth providers. If you want to use Flask-Dance with an OAuth provider that isn’t listed here, simply create an instance of OAuth1ConsumerBlueprint or OAuth2ConsumerBlueprint and provide the information for your provider. We also welcome pull requests to add new pre-set configurations to Flask-Dance!

Included Configurations

Github

flask_dance.contrib.github.make_github_blueprint(client_id, client_secret, scope=None, redirect_url=None, redirect_to=None, login_url=None, authorized_url=None, session_class=None)

Make a blueprint for authenticating with Github using OAuth 2.

Parameters :
  • client_id (str) – The client ID for your application on Github
  • client_secret (str) – The client secret for your application on Github
  • scope (str, optional) – comma-separated list of scopes for the OAuth token
  • redirect_url (str) – the URL to redirect to after the authentication dance is complete
  • redirect_to (str) – if redirect_url is not defined, the name of the view to redirect to after the authentication dance is complete. The actual URL will be determined by flask.url_for()
  • login_url (str, optional) – the URL path for the login view. Defaults to /github
  • authorized_url (str, optional) – the URL path for the authorized view. Defaults to /github/authorized.
  • session_class (class, optional) – The class to use for creating a Requests session. Defaults to OAuth2SessionWithBaseURL.
Return type:

OAuth2ConsumerBlueprint

Returns:

A blueprint to attach to your Flask app.

flask_dance.contrib.github.github

A LocalProxy to a requests.Session that already has the Github authentication token loaded (assuming that the user has authenticated with Github at some point in the past).

Google

flask_dance.contrib.google.make_google_blueprint(client_id, client_secret, scope=None, redirect_url=None, redirect_to=None, login_url=None, authorized_url=None, session_class=None)[source]

Make a blueprint for authenticating with Google using OAuth 2.

Parameters :
  • client_id (str) – The client ID for your application on Github
  • client_secret (str) – The client secret for your application on Github
  • scope (str, optional) – comma-separated list of scopes for the OAuth token. Defaults to the “profile” scope.
  • redirect_url (str) – the URL to redirect to after the authentication dance is complete
  • redirect_to (str) – if redirect_url is not defined, the name of the view to redirect to after the authentication dance is complete. The actual URL will be determined by flask.url_for()
  • login_url (str, optional) – the URL path for the login view. Defaults to /google
  • authorized_url (str, optional) – the URL path for the authorized view. Defaults to /google/authorized.
  • session_class (class, optional) – The class to use for creating a Requests session. Defaults to OAuth2SessionWithBaseURL.
Return type:

OAuth2ConsumerBlueprint

Returns:

A blueprint to attach to your Flask app.

flask_dance.contrib.google.google

A LocalProxy to a requests.Session that already has the Google authentication token loaded (assuming that the user has authenticated with Google at some point in the past).

Twitter

flask_dance.contrib.twitter.make_twitter_blueprint(api_key, api_secret, redirect_url=None, redirect_to=None, login_url=None, authorized_url=None, session_class=None)[source]

Make a blueprint for authenticating with Twitter using OAuth 1.

Parameters :
  • api_key (str) – The API key for your Twitter application
  • api_secret (str) – The API secret for your Twitter application
  • redirect_url (str) – the URL to redirect to after the authentication dance is complete
  • redirect_to (str) – if redirect_url is not defined, the name of the view to redirect to after the authentication dance is complete. The actual URL will be determined by flask.url_for()
  • login_url (str, optional) – the URL path for the login view. Defaults to /twitter
  • authorized_url (str, optional) – the URL path for the authorized view. Defaults to /twitter/authorized.
  • session_class (class, optional) – The class to use for creating a Requests session. Defaults to OAuth1SessionWithBaseURL.
Return type:

OAuth1ConsumerBlueprint

Returns:

A blueprint to attach to your Flask app.

flask_dance.contrib.twitter.twitter

A LocalProxy to a requests.Session that already has the Twitter authentication token loaded (assuming that the user has authenticated with Twitter at some point in the past).

JIRA

flask_dance.contrib.jira.make_jira_blueprint(consumer_key, rsa_key, base_url, redirect_url=None, redirect_to=None, login_url=None, authorized_url=None, session_class=None)

Make a blueprint for authenticating with JIRA using OAuth 1.

Parameters :
  • consumer_key (str) – The consumer key for your Application Link on JIRA
  • rsa_key (str or path) – The RSA private key for your Application Link on JIRA. This can be the contents of the key as a string, or a path to the key file on disk.
  • base_url (str) – The base URL of your JIRA installation. For example, for Atlassian’s hosted OnDemand JIRA, the base_url would be https://jira.atlassian.com
  • redirect_url (str) – the URL to redirect to after the authentication dance is complete
  • redirect_to (str) – if redirect_url is not defined, the name of the view to redirect to after the authentication dance is complete. The actual URL will be determined by flask.url_for()
  • login_url (str, optional) – the URL path for the login view. Defaults to /jira
  • authorized_url (str, optional) – the URL path for the authorized view. Defaults to /jira/authorized.
  • session_class (class, optional) – The class to use for creating a Requests session. Defaults to OAuth1SessionWithBaseURL.
Return type:

OAuth1ConsumerBlueprint

Returns:

A blueprint to attach to your Flask app.

flask_dance.contrib.jira.jira

A LocalProxy to a requests.Session that already has the JIRA authentication token loaded (assuming that the user has authenticated with JIRA at some point in the past).

Table Of Contents

Related Topics

This Page