Skip to main content

Muffin‑OAuth

Muffin‑OAuth adds OAuth 1 and 2 support to the Muffin_ framework, enabling both client-side and server-side authentication flows.

Tests Status PyPI Version Python Versions

Requirements

  • Python >= 3.10
  • Compatible with asyncio, Trio, and Curio

Installation

Install via pip:

pip install muffin-oauth

Usage

Here's a basic example using OAuth2:

from muffin import Application
from muffin_oauth import OAuthPlugin

app = Application("auth-example")
oauth = OAuthPlugin()
oauth.setup(app, providers={
    "github": {
        "client_id": "...",
        "client_secret": "...",
        "authorize_url": "https://github.com/login/oauth/authorize",
        "access_token_url": "https://github.com/login/oauth/access_token",
        "api_base_url": "https://api.github.com"
    }
})

@app.route("/")
async def login(request):
    return await oauth.authorize_redirect(request, "github", redirect_uri="http://localhost:8000/callback")

@app.route("/callback")
async def callback(request):
    token = await oauth.authorize_access_token(request, "github")
    request.session["token"] = token
    return "Logged in"

@app.route("/user")
async def user(request):
    client = oauth.client("github", token=request.session.get("token"))
    resp = await client.get("/user")
    return resp.json()

Run the example app:

$ make example
http://localhost:5000

Client-side usage:

client = oauth.client("github", access_token="...")
resp = await client.request("GET", "/user")
user_info = resp.json()

This supports both OAuth1 and OAuth2 flows, with automatic token handling and resource access via configured providers.

Testing & Security

  • Test coverage for major flows is provided in tests.py.
  • Minimal dependencies and async-native design.
  • Production-ready, MIT-licensed.

Bug Tracker & Contributing

Found an issue or have an idea? Report it at: https://github.com/klen/muffin-oauth/issues

Contributions welcome! Fork the repo and submit a PR.

Contributors

  • klen (Kirill Klenov)

License

Licensed under the MIT license.

Metadata

Release files for muffin-oauth 2.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for muffin-oauth 2.8.1
File Size Uploaded
muffin_oauth-2.8.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for muffin-oauth 2.8.1
File Interpreter ABI Platform
muffin_oauth-2.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / muffin_oauth-2.8.1.tar.gz

Download URL muffin_oauth-2.8.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
16fb4079541b754cb3f8f89a5ddd334993a616f74af7319e8f52c6409647a845
BLAKE2b-256 checksum
How to use checksums
b1f6c7bd76dba88c8f978f8cededb42d9c328f4f9dbf977767398117baa10939
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1018-azure

Release files / muffin_oauth-2.8.1-py3-none-any.whl

Download URL muffin_oauth-2.8.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da6ecc7cc08641f69e40a9168f52db50959d9688913d77971b38d1a70d5f15a2
BLAKE2b-256 checksum
How to use checksums
71e00d1213ca20b61a675f3dcf177ec396b1ad75a961a5f9862fb5065e8f8903
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

2.8.1 This release

2 release files

2.7.1

2 release files

2.6.0

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page