cred-auth
Python SDK for Cred. OAuth2 credential delegation for AI agents. Tokens are brokered, never exposed.
Install
pip install cred-auth
Quick Start
import os
from cred import Cred, ConsentRequiredError
cred = Cred(agent_token=os.environ["CRED_AGENT_TOKEN"])
try:
result = cred.delegate(
service="google",
user_id="user_123",
app_client_id="my_app_client_id",
scopes=["calendar.readonly"],
)
print(result.access_token)
except ConsentRequiredError as e:
# Redirect user to e.consent_url to complete OAuth consent
print(f"Redirect user to: {e.consent_url}")
API
Cred(agent_token, base_url=...)
delegate(service, user_id, app_client_id, scopes=None) → DelegationResult
Get a delegated access token for a service on behalf of a user.
Raises ConsentRequiredError (with .consent_url) if the user hasn't connected the service.
get_user_connections(user_id, app_client_id=None) → list[Connection]
List all active service connections for a user.
get_consent_url(service, user_id, app_client_id, scopes, redirect_uri) → str
Build a consent URL. Pure URL construction, no HTTP call.
revoke(service, user_id, app_client_id=None) → None
Revoke a user's connection to a service.
Context Manager
with Cred(agent_token=token) as cred:
result = cred.delegate(service="github", user_id="u1", app_client_id="app1")
Self-Hosted Server Mode
Point base_url at your own @credninja/server deployment when you want a separate credential broker instead of local-only usage.
Metadata
Release files for cred-auth 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 | |
|---|---|---|---|
| cred_auth-1.0.0.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cred_auth-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.0 kB
Release files / cred_auth-1.0.0.tar.gz
| Download URL | cred_auth-1.0.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
928e92c55e923dc03a491b42f1215eb9347801bb2d22ca784366571d1d4e8764
|
|
BLAKE2b-256 checksum How to use checksums |
06c058935cfac3d1b27fe7b09a7450412fb125b737ac9a493173487fb09e0326
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / cred_auth-1.0.0-py3-none-any.whl
| Download URL | cred_auth-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e1d837c9147427d200146819d8a60b8c07865d294ebbf779a8da3424adf1b64
|
|
BLAKE2b-256 checksum How to use checksums |
b6998940138f90211bc88c1bd154cf0b8809d79614e951c6fe6d827d92e57fa6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|