Skip to main content

Cred — credential delegation SDK for AI agents

Project description

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.

Project details


Download files

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

Source Distribution

cred_auth-1.0.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

cred_auth-1.0.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file cred_auth-1.0.0.tar.gz.

File metadata

  • Download URL: cred_auth-1.0.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cred_auth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 928e92c55e923dc03a491b42f1215eb9347801bb2d22ca784366571d1d4e8764
MD5 6de15cadc22cf65ee0c1a077e8bde3e0
BLAKE2b-256 06c058935cfac3d1b27fe7b09a7450412fb125b737ac9a493173487fb09e0326

See more details on using hashes here.

File details

Details for the file cred_auth-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cred_auth-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cred_auth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e1d837c9147427d200146819d8a60b8c07865d294ebbf779a8da3424adf1b64
MD5 cd80c30584c64b5dd7f8490838faa931
BLAKE2b-256 b6998940138f90211bc88c1bd154cf0b8809d79614e951c6fe6d827d92e57fa6

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