Skip to main content

Turbo Agent 授权管理库,支持基于平台授权方法与秘钥的登录、刷新与请求鉴权

Project description

turbo-agent-auth

Turbo Agent 授权管理库。提供基于 turbo-agent-core 中定义的 PlatformAuthMethodSecret 数据模型,执行多步登录流程、凭据刷新、请求鉴权注入等能力。

定位

  • 纯库,不包含数据库、HTTP 服务等基础设施依赖
  • 不做凭据持久化——只负责授权流程的执行与 HTTP 请求的鉴权注入
  • 存储由上层模块(cloud / store)负责

核心能力

  1. 登录流程执行 (AuthFlowExecutor):基于 AuthMethod.loginFlow 定义的多步模板,渲染占位符、发送请求、解析响应、提取凭据
  2. 同步/异步授权客户端 (AuthClient / AsyncAuthClient):封装 Platform + AuthMethod + Secret,提供 login() / refresh() / request() 等方法
  3. 请求鉴权注入 (BaseAuthClient.prepare_http()):根据 authFieldPlacements 将 Token/Cookie/APIKey 注入到 HTTP 请求的 Header/Query/Cookie/Body 中
  4. 默认授权模板 (get_default_schemas()):内置 JWT、OAuth1/2、APIKey、Cookies、SMTP、POP3 的默认字段与流程模板
  5. SMTP/POP3 邮件支持 (AuthClient.smtp_send() / AuthClient.pop3_fetch())

安装

uv add turbo-agent-auth

快速使用

from turbo_agent_core.schema.external import Platform, AuthMethod, Secret
from turbo_agent_auth import AuthClient, AsyncAuthClient

# 构造平台、授权方式、秘钥实例(通常从 store 读取)
platform = Platform(...)
auth_method = AuthMethod(...)
secret = Secret(...)

# 同步客户端
client = AuthClient(platform, auth_method, secret)
client.login()  # 执行登录流程,更新 secret.credential
resp = client.get("/api/some-endpoint")  # 自动注入鉴权信息

# 异步客户端
async_client = AsyncAuthClient(platform, auth_method, secret)
await async_client.login()
resp = await async_client.get("/api/some-endpoint")

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

turbo_agent_auth-0.1.10rc2.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

turbo_agent_auth-0.1.10rc2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file turbo_agent_auth-0.1.10rc2.tar.gz.

File metadata

  • Download URL: turbo_agent_auth-0.1.10rc2.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for turbo_agent_auth-0.1.10rc2.tar.gz
Algorithm Hash digest
SHA256 f7e1159e72c3ba5d1fc3f2a9ac58f652a2950adcd0a9a99abe35ae4f165d926d
MD5 a965a986b1a046d1c78e5c1aaf897aa6
BLAKE2b-256 e066ac9f02cfaf04275f9a2abfeb448fd0dd7a7248e4382607e9eb930c40f91a

See more details on using hashes here.

File details

Details for the file turbo_agent_auth-0.1.10rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for turbo_agent_auth-0.1.10rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 a6c71120470b7487bb7fede04652128eb3866b89875063f7bc0567bfb26e5576
MD5 4229e26b3ca2b42f65dc7c6778c0cc9d
BLAKE2b-256 81de3b4ba285b65ec20f8c9c78541bc63f6a6bd49e6273e28ce0601383094a3d

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