FastAPI plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 Account)
Project description
FastAPI SSO
FastAPI plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 account).
This allows you to implement the famous Login with Google/Facebook/Microsoft
buttons functionality on your backend very easily.
Installation
Install using pip
pip install fastapi-sso
Install using poetry
poetry add fastapi-sso
Example
example.py
"""This is an example usage of fastapi-sso.
"""
from fastapi import FastAPI
from starlette.requests import Request
from fastapi_sso.sso.google import GoogleSSO
app = FastAPI()
google_sso = GoogleSSO("my-client-id", "my-client-secret", "https://my.awesome-web.com/google/callback")
@app.get("/google/login")
async def google_login():
"""Generate login url and redirect"""
return await google_sso.get_login_redirect()
@app.get("/google/callback")
async def google_callback(request: Request):
"""Process login response from Google and return user info"""
user = await google_sso.verify_and_process(request)
return {
"id": user.id,
"picture": user.picture,
"display_name": user.display_name,
"email": user.email,
"provider": user.provider,
}
Run using uvicorn example:app
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastapi-sso-0.2.5.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_sso-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c527acd1e6d974f4dfcf2cfc1e8c07b130f071386341b86f911ac1ed84166fc |
|
MD5 | f9871e9f2ebfdc310c96556c60844c37 |
|
BLAKE2b-256 | d8014cc80fc85cdeb2be232667202fc63f36c161ada9be97e49dfd94c9e73e6c |