Asynchronous OAuth 2.0 client for such platforms as Google, GitHub, Yandex, etc.
Project description
FastLink
Effortless asynchronous OAuth 2.0 client for popular platforms
Features
- Asynchronous: Built on top of
httpxis fully asynchronous. - Built-in support: For popular OAuth 2.0 providers like Google, Yandex, Telegram, etc.
- Extensible: Easily add support for new OAuth 2.0 providers.
- Easy to use: Simple and intuitive API.
Installation
pip install fastlink
Get Started
from typing import Annotated
from fastapi import FastAPI, Depends
from starlette.responses import RedirectResponse
from fastlink.google.client import GoogleOAuth
from fastlink.client.schemas import OAuth2Callback, OpenID
from examples.config import settings
app = FastAPI()
oauth = GoogleOAuth(
settings.google_client_id,
settings.google_client_secret,
"http://localhost:8000/callback",
)
@app.get("/login")
async def login() -> RedirectResponse:
async with oauth:
url = await oauth.get_authorization_url()
return RedirectResponse(url=url)
@app.get("/callback")
async def oauth_callback(callback: Annotated[OAuth2Callback, Depends()]) -> OpenID:
async with oauth:
await oauth.authorize(callback)
return await oauth.userinfo()
Now you can run the server and visit http://localhost:8000/login to start the OAuth 2.0 flow.
After logging into Google, you will be redirected to the callback URL. The server will then fetch the user's OpenID
information and return it as a response.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastlink-0.1.0.tar.gz.
File metadata
- Download URL: fastlink-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4cfd89e44e215539fbdc17dd05b005a40f4d141ac1bddb6c3bd3cc063e378fe
|
|
| MD5 |
0811bd4d66b959c05733f82627bbfef9
|
|
| BLAKE2b-256 |
fe9919cd98129f8c721559a6328282486568fa9c4964124d63aa4bc8f07dd8cc
|
File details
Details for the file fastlink-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastlink-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58ae5b77fb897e7c046d947bc5a3637df4123fb4ae73236989b5af4f228e2b29
|
|
| MD5 |
9a51d5ad24f13045adcfa3867d3f552d
|
|
| BLAKE2b-256 |
42684b745efa8e23c7816e5b7b86a64504c0cf9de82235a2f7865e007837bca3
|