Ready to Use Apps

There are built-in configuration for famous services. Import them and register them to frameworks registry. If you haven’t read Integrated Frameworks, head over back to that section.

Twitter

Register Twitter to the oauth registry:

from authlib.client.apps import twitter

twitter.register_to(oauth)

If you are using Flask, you need to configure the consumer key and secret:

TWITTER_CLIENT_KEY Twitter Consumer Key
TWITTER_CLIENT_SECRET Twitter Consumer Secret

If you are using Django, you need to configure consumer key and secret in settings:

AUTHLIB_OAUTH_CLIENTS = {
    'twitter': {
        'client_key': 'Twitter Consumer Key',
        'client_secret': 'Twitter Consumer Secret',
    }
}

You are use the twitter instance directly, or access it from oauth registry:

twitter.authorize_redirect(callback_uri)  # Flask
twitter.authorize_redirect(request, callback_uri)  # Django

There is a built-in fetch_user in every app, you can get the user info with a simple function invoke:

user = twitter.fetch_user()
# user contains: id, name, email, data

Facebook

Register Facebook to the oauth registry:

from authlib.client.apps import facebook

facebook.register_to(oauth)

If you are using Flask, you need to configure your client ID and secret.

FACEBOOK_CLIENT_KEY Your Facebook client ID
FACEBOOK_CLIENT_SECRET Your Facebook client secret
FACEBOOK_CLIENT_KWARGS Configure scope and other things

The default scope in FACEBOOK_CLIENT_KWARGS is email public_profile.

For Django registry, configure client ID and secret in settings:

AUTHLIB_OAUTH_CLIENTS = {
    'facebook': {
        'client_key': 'Facebook Client ID',
        'client_secret': 'Facebook Client Secret',
        'client_kwargs': {'scope': 'Redefine scope here'},
    }
}

It has a built-in fetch_user method too.

Google

Register Google to the oauth registry:

from authlib.client.apps import google

google.register_to(oauth)

If you are using Flask, you need to configure your client ID and secret.

GOOGLE_CLIENT_KEY Your Google client ID
GOOGLE_CLIENT_SECRET Your Google client secret
GOOGLE_CLIENT_KWARGS Configure scope and other things

The default scope in GOOGLE_CLIENT_KWARGS is openid email profile. Although there is a fetch_user method with Google app, you don’t have to use it, since Google supports OpenID Connect:

>>> token = google.authorize_access_token()
>>> user = google.parse_openid(token)

GitHub

Register GitHub to the oauth registry:

from authlib.client.apps import github

github.register_to(oauth)

If you are using Flask, you need to configure your client ID and secret.

GITHUB_CLIENT_KEY Your GitHub client ID
GITHUB_CLIENT_SECRET Your GitHub client secret
GITHUB_CLIENT_KWARGS Configure scope and other things

The default scope in GITHUB_CLIENT_KWARGS is user:email.

For Django registry, configure client ID and secret in settings:

AUTHLIB_OAUTH_CLIENTS = {
    'github': {
        'client_key': 'GitHub Client ID',
        'client_secret': 'GitHub Client Secret',
        'client_kwargs': {'scope': 'Redefine scope here'},
    }
}

It has a built-in fetch_user method too.

Dropbox

Register Dropbox to the oauth registry:

from authlib.client.apps import dropbox

dropbox.register_to(oauth)

If you are using Flask, you need to configure your client ID and secret.

DROPBOX_CLIENT_KEY Your Dropbox client ID
DROPBOX_CLIENT_SECRET Your Dropbox client secret
DROPBOX_CLIENT_KWARGS Configure scope and other things

There is no default scope for Dropbox.

For Django registry, configure client ID and secret in settings:

AUTHLIB_OAUTH_CLIENTS = {
    'dropbox': {
        'client_key': 'Dropbox Client ID',
        'client_secret': 'Dropbox Client Secret',
        'client_kwargs': {'scope': 'Redefine scope here'},
    }
}

It has a built-in fetch_user method too.