AI agents can use the SimplePost documentation index at /llms.txt to find related guides.
Bluesky OAuth 应用设置
Bluesky 使用 AT Protocol OAuth。这里没有集中的开发者应用注册门户。你的应用通过一份公开的客户端元数据 JSON 文档来标识。
托管版 Scheduler 会提供其自己的 Bluesky OAuth 客户端。本地 CLI 的 OAuth 连接需要在 SIMPLE_POST_BLUESKY_CLIENT_ID 中使用你自己托管的客户端元数据 URL。如果想要更简单的本地 SDK 设置,可以使用应用专用密码(app password);也可以将 CLI 连接到托管版 Scheduler,以复用已有账号。
客户端元数据
将一份 JSON 文档托管在公开的 HTTPS URL 上。该文档的 URL 同时也是 client_id。
浏览器或公共客户端示例:
{
"client_id": "https://yourapp.com/oauth/client-metadata.json",
"application_type": "web",
"client_name": "Your App Name",
"client_uri": "https://yourapp.com",
"dpop_bound_access_tokens": true,
"grant_types": ["authorization_code", "refresh_token"],
"redirect_uris": ["https://yourapp.com/oauth/callback"],
"response_types": ["code"],
"scope": "atproto transition:generic",
"token_endpoint_auth_method": "none"
}
机密服务端客户端示例:
{
"client_id": "https://yourapp.com/oauth/client-metadata.json",
"application_type": "web",
"client_name": "Your App Name",
"client_uri": "https://yourapp.com",
"dpop_bound_access_tokens": true,
"grant_types": ["authorization_code", "refresh_token"],
"redirect_uris": ["https://yourapp.com/oauth/callback"],
"response_types": ["code"],
"scope": "atproto transition:generic",
"token_endpoint_auth_method": "private_key_jwt",
"token_endpoint_auth_signing_alg": "ES256",
"jwks": {
"keys": [
{
"kty": "EC",
"crv": "P-256",
"x": "YOUR_PUBLIC_KEY_X",
"y": "YOUR_PUBLIC_KEY_Y",
"kid": "key-1"
}
]
}
}
必填字段
| 字段 | 是否必填 | 说明 |
|---|---|---|
client_id | 是 | 必须与元数据 URL 完全一致。 |
dpop_bound_access_tokens | 是 | 必须为 true。 |
grant_types | 是 | 使用 authorization_code 和 refresh_token。 |
redirect_uris | 是 | 回调 URL 列表。 |
response_types | 是 | 使用 code。 |
scope | 是 | 必须包含 atproto。 |
token_endpoint_auth_method | 否 | 公共客户端使用 none,机密客户端使用 private_key_jwt。 |
生成 ES256 密钥
使用 Node.js:
import crypto from "node:crypto";
const { privateKey, publicKey } = crypto.generateKeyPairSync("ec", {
namedCurve: "P-256",
});
const privateJwk = privateKey.export({ format: "jwk" });
const publicJwk = publicKey.export({ format: "jwk" });
privateJwk.kid = "key-1";
publicJwk.kid = "key-1";
console.log("Public JWK:", JSON.stringify(publicJwk, null, 2));
console.log("Private JWK:", JSON.stringify(privateJwk, null, 2));
请将私钥保存在密钥管理器或加密的服务器配置中。公钥则放入元数据文档。
OAuth 流程要求
Bluesky OAuth 使用:
- 用于授权码交换的 PKCE。
- PAR,即推送式授权请求(pushed authorization requests)。
- 用于令牌请求和 API 请求的 DPoP 证明。
- 对来自
DPoP-Nonce标头的 nonce 进行处理。
Scheduler 已为已连接的 Bluesky 账号实现了这些机制。如果你要构建自己的 OAuth 流程,请尽可能使用官方的 AT Protocol OAuth 库。