better-auth-client
Python HTTP client for better-auth
servers: the TypeScript original, or
better-auth-server on the same wire.
pip install better-auth-client
Quickstart
Sync (httpx.Client):
from better_auth_client import AuthClient
client = AuthClient("http://localhost:8000") # base_path defaults to /api/auth
client.sign_up.email(name="Ada", email="ada@example.com", password="s3cret-password")
client.sign_in.email(email="ada@example.com", password="s3cret-password")
session = client.get_session() # dict, or None when unauthenticated
client.sign_out()
Async (httpx.AsyncClient) is the same surface, awaited:
from better_auth_client import AsyncAuthClient
client = AsyncAuthClient("http://localhost:8000")
await client.sign_in.email(email="ada@example.com", password="s3cret-password")
session = await client.get_session()
Kwargs are sent verbatim as wire keys (JSON body on POST, query params on GET), so
camelCase wire fields stay camelCase: client.sign_in.social(provider=..., callbackURL=...).
Errors raise APIError(status, code, message, body) with the exact wire code.
Redirect responses (e.g. the OAuth authorization step) are returned as-is, never
followed.
Service-to-service
Validate a forwarded session token (server bearer plugin) without cookies:
client = AuthClient("http://auth.internal")
client.set_bearer(forwarded_token) # from the set-auth-token response header
session = client.get_session() # None if the token is invalid/expired
When the server has the bearer plugin enabled, the client also captures
set-auth-token automatically after sign-in.
Device flow (RFC 8628)
For CLIs and other input-constrained clients (server device-authorization plugin):
flow = client.device.flow("my-cli")
print(f"Visit {flow.verification_uri} and enter {flow.user_code}")
token = flow.poll() # blocks (awaits, for AsyncAuthClient)
client.set_bearer(token["access_token"])
poll() honors the server's interval, backs off on slow_down, keeps waiting on
authorization_pending, and raises APIError on denial or expiry.
Coverage
158 endpoints, mirroring the server routes: the full core surface plus
sign_in.*:email,social,username,phone_number,anonymous,magic_link,email_otp,oauth2(generic-oauth),ssotwo_factor,organization(teams and dynamic roles included),admin,api_key,magic_link,email_otp,devicephone_number,passkey,siwe,one_tap,one_time_token,multi_session,sso(domain verification included)oauth2: generic-oauth (link) plus the whole oauth-provider surface (DCRregister, client CRUD,client.rotate_secret,authorize,token,introspect,revoke,userinfo,end_session, consent + consent CRUD)- root-mounted jwt-plugin routes as
token()/jwks(), plusis_username_available()anddelete_anonymous_user()
Server plugins without mounted routes need no client namespace: bearer
(automatic set-auth-token capture, above), captcha, have-i-been-pwned,
last-login-method, custom-session (shadows get_session), oauth-proxy
(browser-redirect callback only), oauth-popup (popup navigation only).
The rule for what is included: an entry exists when the request is genuinely
emitted by a Python program, whether headless or relaying for a browser (BFF,
server-rendered pages, CLIs). Routes only the end user's own browser ever
requests (/oauth2/continue, /oauth-popup/start, redirect callbacks) are
deliberately not part of the client.
Release files for better-auth-client 1.0.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 | |
|---|---|---|---|
| better_auth_client-1.0.0.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| better_auth_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / better_auth_client-1.0.0.tar.gz
| Download URL | better_auth_client-1.0.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd9cadc6a18f2bb1828e0f6300dc3b967bd99c4707f1ec82479f20d1959c67ae
|
|
BLAKE2b-256 checksum How to use checksums |
d47a709d35b2a5d9f715cf93779e187f609fe1a07964f68273f2d5ac0a7c617c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","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 / better_auth_client-1.0.0-py3-none-any.whl
| Download URL | better_auth_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f66eec5f2c69f4bb0cbf3a2eb7af77e62ca6b8d50d0d514a2363303c9929bc85
|
|
BLAKE2b-256 checksum How to use checksums |
3addb6a543f3372359d470525f7c5ba0477ebcba49d08da4791bb4aa00205981
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","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}
|