Skip to main content

Asynchronous OAuth 2.0 client for such platforms as Google, GitHub, Yandex, etc.

Project description

Auth365

Effortless asynchronous OAuth 2.0 client for popular platforms


Test CodeQL Advanced


Features

  • Asynchronous: Built on top of httpx is fully asynchronous.
  • Built-in support: For popular OAuth 2.0 providers like Google, GitHub, Yandex, etc.
  • Extensible: Easily add support for new OAuth 2.0 providers.
  • Easy to use: Simple and intuitive API.

Installation

  pip install auth365

Get Started

from typing import Annotated

from fastapi import FastAPI, Depends
from starlette.responses import RedirectResponse

from auth365.providers.google import GoogleOAuth
from auth365.schemas import OAuth2Callback, OpenID
from examples.config import settings

app = FastAPI()

google_oauth = GoogleOAuth(
    client_id=settings.google_client_id,
    client_secret=settings.google_client_secret,
    redirect_uri="http://localhost:8000/callback",
)


@app.get("/login")
async def login() -> RedirectResponse:
    async with google_oauth:
        url = await google_oauth.get_authorization_url()
        return RedirectResponse(url=url)


@app.get("/callback")
async def oauth_callback(callback: Annotated[OAuth2Callback, Depends()]) -> OpenID:
    async with google_oauth:
        await google_oauth.authorize(callback)
        return await google_oauth.userinfo()

Now you can run the server and visit http://localhost:8000/login to start the OAuth 2.0 flow.

screenshot-1738081195921.png

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. screenshot-1738081352079.png

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auth365-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auth365-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file auth365-0.1.0.tar.gz.

File metadata

  • Download URL: auth365-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11

File hashes

Hashes for auth365-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0c87c3a386b910106ef0455471e204764e51a69291a20cb5b2c246f27eff198
MD5 a0a3f40b9e781ea38cf6c6ab627dbfbf
BLAKE2b-256 5e493fb28e3ad15ac94d8b0bed17dfdd47909627c07b2cfcaf25cf88e7245501

See more details on using hashes here.

File details

Details for the file auth365-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: auth365-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Windows/11

File hashes

Hashes for auth365-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9107bf245e1f201f1265ad1b27636c3dc095cf405b49237e7067b037ea4cbbb4
MD5 95284d395970e772202c1087e6b3312c
BLAKE2b-256 ee10bb028eebef8fa1ab263d9a9483a65927c94ef6f2b48d5e6ad88c43217f5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page