atproto-oauth
OAuth 2.1 client for the AT Protocol: pushed authorization requests, PKCE, DPoP with nonce rotation, token refresh and revocation, and scope parsing. It works with any account on any PDS, and re-verifies the DID → PDS → authorization server chain after every token exchange.
It builds on the atproto SDK for identity resolution. The same code is proposed for the SDK itself in MarshalX/atproto#636; this package exists so projects can depend on it from PyPI until the SDK ships OAuth.
uv add atproto-oauth
from atproto_oauth import OAuthClient
from atproto_oauth.stores import MemorySessionStore, MemoryStateStore
client = OAuthClient(
client_id="https://app.example.com/oauth-client-metadata.json",
redirect_uri="https://app.example.com/oauth/callback",
scope="atproto",
state_store=MemoryStateStore(),
session_store=MemorySessionStore(),
)
# send the user to auth_url; your callback receives code, state and iss
auth_url, state = await client.start_authorization("alice.example.com")
session = await client.handle_callback(code=code, state=state, iss=iss)
response = await client.make_authenticated_request(
session=session,
method="GET",
url=f"{session.pds_url}/xrpc/com.atproto.repo.describeRepo?repo={session.did}",
)
For local development, a client ID of http://localhost makes it a loopback client with no hosted metadata; use http://127.0.0.1 in the redirect URI.
Set ATPROTO_USER_AGENT to replace httpx's default User-Agent for the whole process.
Release files for atproto-oauth 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| atproto_oauth-0.1.0.tar.gz | 139.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| atproto_oauth-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 171.7 kB
Release files / atproto_oauth-0.1.0.tar.gz
| Download URL | atproto_oauth-0.1.0.tar.gz |
|---|---|
| Size | 139.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27a4aa77dd7441d42f08c3a8f0a2a2c50dd2740380a5a01837d3d24fd216bcf4
|
|
BLAKE2b-256 checksum How to use checksums |
129df01fde902a7e53bdebb1698869e1656aaec82326a9be0a9eca791df5ec4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / atproto_oauth-0.1.0-py3-none-any.whl
| Download URL | atproto_oauth-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abc3c8c8605edd32db9126de1e3ce14c11116744b5e03d7753185160f7fbfe45
|
|
BLAKE2b-256 checksum How to use checksums |
975fc8dcb29d343d89cff27be54f9d373adeb1e2e469ee68a89ff70aaebc5435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|