You can download this code by clicking the button below.
This code is now available for download.
This function creates a GitHub OAuth client in a Flask application, allowing users to log in via GitHub.
Technology Stack : Authlib, Flask
Code Type : Function
Code Difficulty : Intermediate
from authlib.integrations.flask_client import OAuth
def create_oauth_client(app):
oauth = OAuth(app)
github = oauth.register(
name='github',
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
access_token_url='https://github.com/login/oauth/access_token',
access_token_params=None,
authorize_url='https://github.com/login/oauth/authorize',
authorize_params=None,
api_base_url='https://api.github.com',
client_kwargs={'scope': 'user:email'}
)
return github