Flask Social OAuth is a Python package that simplifies the integration of social oauth functionality into Flask web applications. With support for popular social authentication providers like Google, GitHub, and Discord, Flask Social OAuth streamlines the authentication process for users and enables seamless access to your web application.
You can install Flask Social OAuth via pip:
pip install flask-social-oauth
from flask import Flask, session
from flask_social_oauth import Config, initialize_social_login
app = Flask(__name__)
app.secret_key = 'your_secret_key'
# Configure social authentication providers
config = Config()
config.google_auth(
google_auth_client_id="your_client_id",
google_auth_client_secret="your_client_secret"
)
config.github_auth(
github_auth_client_id="your_client_id",
github_auth_client_secret="your_client_secret"
)
config.discord_auth(
discord_auth_client_id="your_client_id",
discord_auth_client_secret="your_client_secret"
)
# Initialize social login
initialize_social_login(session, app, config)
if __name__ == '__main__':
app.run(debug=True)
- GitHub
- Discord
The Config
class is used to define the configuration settings for Flask Social Login package. It provides methods to configure authentication parameters for different social providers.
google_auth()
: Configures Google authentication parameters.github_auth()
: Configures GitHub authentication parameters.discord_auth()
: Configures Discord authentication parameters.
The initialize_social_login()
function is used to initialize social login for the Flask app using the provided configuration settings. It registers URL routes and handlers for social authentication providers.
session
: The Flask session object.app
: The Flask app instance.config
: The configuration settings for Flask Social Login package.
Handles the initiation of the Google OAuth login flow.
config
: The configuration settings for Flask Social Login package.
Handles the Google OAuth callback flow.
config
: The configuration settings for Flask Social Login package.session
: The Flask session object.
Handles the initiation of the GitHub OAuth login flow.
config
: The configuration settings for Flask Social Login package.
Handles the GitHub OAuth callback flow.
config
: The configuration settings for Flask Social Login package.session
: The Flask session object.
Handles the initiation of the Discord OAuth login flow.
config
: The configuration settings for Flask Social Login package.
Handles the Discord OAuth callback flow.
config
: The configuration settings for Flask Social Login package.session
: The Flask session object.
For more detailed usage and configuration, please refer to the documentation.
If you encounter any issues or have suggestions for improvements, feel free to open an issue on GitHub. Contributions are also welcome!
Flask Social OAuth is released under the MIT License.