{"id":99,"date":"2026-03-21T22:47:17","date_gmt":"2026-03-21T14:47:17","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/concepts-oauth\/"},"modified":"2026-03-21T23:08:56","modified_gmt":"2026-03-21T15:08:56","slug":"concepts-oauth","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/concepts-oauth\/","title":{"rendered":"OAuth"},"content":{"rendered":"<h1>OAuth<\/h1>\n<p>OpenClaw \u901a\u8fc7 OAuth \u652f\u6301\u63d0\u4f9b\u5546\u63d0\u4f9b\u7684\u201c\u8ba2\u9605\u8ba4\u8bc1\u201d\uff0c\u9002\u7528\u4e8e\u652f\u6301\u6b64\u65b9\u5f0f\u7684\u63d0\u4f9b\u5546\uff08\u5c24\u5176\u662f <strong>OpenAI Codex\uff08ChatGPT OAuth\uff09<\/strong>\uff09\u3002\u5bf9\u4e8e Anthropic \u8ba2\u9605\uff0c\u8bf7\u4f7f\u7528 <strong>setup-token<\/strong> \u6d41\u7a0b\u3002\u8fc7\u53bb\u6709\u4e9b\u7528\u6237\u5728 Claude Code \u4e4b\u5916\u4f7f\u7528 Anthropic \u8ba2\u9605\u65f6\u66fe\u53d7\u9650\uff0c\u56e0\u6b64\u8fd9\u5e94\u89c6\u4e3a\u7528\u6237\u81ea\u884c\u9009\u62e9\u627f\u62c5\u7684\u98ce\u9669\uff0c\u4f60\u5e94\u81ea\u884c\u6838\u5b9e Anthropic \u5f53\u524d\u7684\u653f\u7b56\u3002OpenAI Codex OAuth \u660e\u786e\u652f\u6301\u5728 OpenClaw \u8fd9\u6837\u7684\u5916\u90e8\u5de5\u5177\u4e2d\u4f7f\u7528\u3002\u672c\u9875\u8bf4\u660e\uff1a<\/p>\n<p>\u5bf9\u4e8e\u751f\u4ea7\u73af\u5883\u4e2d\u7684 Anthropic\uff0c\u76f8\u6bd4\u8ba2\u9605 setup-token \u8ba4\u8bc1\uff0cAPI \u5bc6\u94a5\u8ba4\u8bc1\u662f\u66f4\u5b89\u5168\u3001\u4e5f\u66f4\u63a8\u8350\u7684\u8def\u5f84\u3002<\/p>\n<ul>\n<li>OAuth <strong>\u4ee4\u724c\u4ea4\u6362<\/strong> \u5982\u4f55\u5de5\u4f5c\uff08PKCE\uff09<\/li>\n<li>\u4ee4\u724c<strong>\u5b58\u50a8<\/strong>\u5728\u54ea\u91cc\uff08\u4ee5\u53ca\u4e3a\u4ec0\u4e48\uff09<\/li>\n<li>\u5982\u4f55\u5904\u7406<strong>\u591a\u4e2a\u8d26\u6237<\/strong>\uff08\u914d\u7f6e\u6587\u4ef6 + \u6309\u4f1a\u8bdd\u8986\u76d6\uff09<\/li>\n<\/ul>\n<p>OpenClaw \u4e5f\u652f\u6301\u81ea\u5e26 OAuth \u6216 API \u5bc6\u94a5\u6d41\u7a0b\u7684<strong>\u63d0\u4f9b\u5546\u63d2\u4ef6<\/strong>\u3002\u8fd0\u884c\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw models auth login &#8211;provider <\/p>\n<pre><code>\n## \u4ee4\u724c\u6c47\u70b9\uff08\u4e3a\u4ec0\u4e48\u9700\u8981\u5b83\uff09\n\nOAuth \u63d0\u4f9b\u5546\u901a\u5e38\u4f1a\u5728\u767b\u5f55\/\u5237\u65b0\u6d41\u7a0b\u4e2d\u7b7e\u53d1\u4e00\u4e2a**\u65b0\u7684\u5237\u65b0\u4ee4\u724c**\u3002\u67d0\u4e9b\u63d0\u4f9b\u5546\uff08\u6216 OAuth \u5ba2\u6237\u7aef\uff09\u4f1a\u5728\u4e3a\u540c\u4e00\u7528\u6237\/\u5e94\u7528\u7b7e\u53d1\u65b0\u4ee4\u724c\u65f6\u4f7f\u65e7\u7684\u5237\u65b0\u4ee4\u724c\u5931\u6548\u3002\n\n\u5b9e\u9645\u75c7\u72b6\uff1a\n\n* \u4f60\u540c\u65f6\u901a\u8fc7 OpenClaw *\u548c* Claude Code \/ Codex CLI \u767b\u5f55 \u2192 \u4e4b\u540e\u5176\u4e2d\u4e00\u4e2a\u4f1a\u968f\u673a\u201c\u88ab\u767b\u51fa\u201d\n\n\u4e3a\u51cf\u5c11\u8fd9\u79cd\u60c5\u51b5\uff0cOpenClaw \u5c06 `auth-profiles.json` \u89c6\u4e3a\u4e00\u4e2a**\u4ee4\u724c\u6c47\u70b9**\uff1a\n\n* \u8fd0\u884c\u65f6\u4ece**\u540c\u4e00\u4e2a\u5730\u65b9**\u8bfb\u53d6\u51ed\u8bc1\n* \u6211\u4eec\u53ef\u4ee5\u4fdd\u7559\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u8fdb\u884c\u786e\u5b9a\u6027\u8def\u7531\n\n## \u5b58\u50a8\uff08\u4ee4\u724c\u5b58\u653e\u4f4d\u7f6e\uff09\n\n\u5bc6\u94a5\u6309**\u6bcf\u4e2a\u667a\u80fd\u4f53**\u5b58\u50a8\uff1a\n\n* \u8ba4\u8bc1\u914d\u7f6e\u6587\u4ef6\uff08OAuth + API \u5bc6\u94a5 + \u53ef\u9009\u7684\u503c\u7ea7\u5f15\u7528\uff09\uff1a`~\/.openclaw\/agents\/&lt;agentId&gt;\/agent\/auth-profiles.json`\n* \u65e7\u7248\u517c\u5bb9\u6587\u4ef6\uff1a`~\/.openclaw\/agents\/&lt;agentId&gt;\/agent\/auth.json`\n  \uff08\u53d1\u73b0\u9759\u6001 `api_key` \u6761\u76ee\u65f6\u4f1a\u8fdb\u884c\u6e05\u7406\uff09\n\n\u4ec5\u7528\u4e8e\u65e7\u7248\u5bfc\u5165\u7684\u6587\u4ef6\uff08\u4ecd\u53d7\u652f\u6301\uff0c\u4f46\u4e0d\u662f\u4e3b\u5b58\u50a8\uff09\uff1a\n\n* `~\/.openclaw\/credentials\/oauth.json`\uff08\u9996\u6b21\u4f7f\u7528\u65f6\u4f1a\u5bfc\u5165\u5230 `auth-profiles.json`\uff09\n\n\u4ee5\u4e0a\u6240\u6709\u4f4d\u7f6e\u4e5f\u90fd\u9075\u5faa `$OPENCLAW_STATE_DIR`\uff08\u72b6\u6001\u76ee\u5f55\u8986\u76d6\uff09\u3002\u5b8c\u6574\u53c2\u8003\uff1a[\/gateway\/configuration](\/gateway\/configuration#auth-storage-oauth--api-keys)\n\n\u6709\u5173\u9759\u6001\u5bc6\u94a5\u5f15\u7528\u548c\u8fd0\u884c\u65f6\u5feb\u7167\u6fc0\u6d3b\u884c\u4e3a\uff0c\u8bf7\u53c2\u89c1 [Secrets Management](\/gateway\/secrets)\u3002\n\n## Anthropic setup-token\uff08\u8ba2\u9605\u8ba4\u8bc1\uff09\n\n&lt;Warning&gt;\n  Anthropic setup-token \u652f\u6301\u662f\u6280\u672f\u517c\u5bb9\u6027\uff0c\u5e76\u975e\u7b56\u7565\u4fdd\u8bc1\u3002\n  Anthropic \u8fc7\u53bb\u66fe\u963b\u6b62\u8fc7\u67d0\u4e9b\u5728 Claude Code \u4e4b\u5916\u7684\u8ba2\u9605\u4f7f\u7528\u3002\n  \u662f\u5426\u4f7f\u7528\u8ba2\u9605\u8ba4\u8bc1\u7531\u4f60\u81ea\u884c\u51b3\u5b9a\uff0c\u5e76\u8bf7\u6838\u5b9e Anthropic \u5f53\u524d\u7684\u6761\u6b3e\u3002\n&lt;\/Warning&gt;\n\n\u5728\u4efb\u610f\u673a\u5668\u4e0a\u8fd0\u884c `claude setup-token`\uff0c\u7136\u540e\u5c06\u5176\u7c98\u8d34\u5230 OpenClaw \u4e2d\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw models auth setup-token --provider anthropic\n<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u662f\u5728\u5176\u4ed6\u5730\u65b9\u751f\u6210\u7684\u4ee4\u724c\uff0c\u53ef\u624b\u52a8\u7c98\u8d34\uff1a<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw models auth paste-token &#8211;provider anthropic<\/p>\n<pre><code>\n\u9a8c\u8bc1\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw models status\n<\/code><\/pre>\n<h2>OAuth \u4ea4\u6362\uff08\u767b\u5f55\u5982\u4f55\u5de5\u4f5c\uff09<\/h2>\n<p>OpenClaw \u7684\u4ea4\u4e92\u5f0f\u767b\u5f55\u6d41\u7a0b\u5728 <code>@mariozechner\/pi-ai<\/code> \u4e2d\u5b9e\u73b0\uff0c\u5e76\u63a5\u5165\u5230\u5404\u7c7b\u5411\u5bfc\/\u547d\u4ee4\u4e2d\u3002<\/p>\n<h3>Anthropic setup-token<\/h3>\n<p>\u6d41\u7a0b\u5f62\u6001\uff1a<\/p>\n<ol>\n<li>\u8fd0\u884c <code>claude setup-token<\/code><\/li>\n<li>\u5c06\u4ee4\u724c\u7c98\u8d34\u5230 OpenClaw<\/li>\n<li>\u5b58\u50a8\u4e3a\u4ee4\u724c\u8ba4\u8bc1\u914d\u7f6e\u6587\u4ef6\uff08\u4e0d\u5237\u65b0\uff09<\/li>\n<\/ol>\n<p>\u5411\u5bfc\u8def\u5f84\u4e3a <code>openclaw onboard<\/code> \u2192 \u8ba4\u8bc1\u9009\u62e9 <code>setup-token<\/code>\uff08Anthropic\uff09\u3002<\/p>\n<h3>OpenAI Codex\uff08ChatGPT OAuth\uff09<\/h3>\n<p>OpenAI Codex OAuth \u660e\u786e\u652f\u6301\u5728 Codex CLI \u4e4b\u5916\u4f7f\u7528\uff0c\u5305\u62ec OpenClaw \u5de5\u4f5c\u6d41\u3002<\/p>\n<p>\u6d41\u7a0b\u5f62\u6001\uff08PKCE\uff09\uff1a<\/p>\n<ol>\n<li>\u751f\u6210 PKCE verifier\/challenge \u548c\u968f\u673a <code>state<\/code><\/li>\n<li>\u6253\u5f00 <code>https:\/\/auth.openai.com\/oauth\/authorize?...<\/code><\/li>\n<li>\u5c1d\u8bd5\u5728 <code>http:\/\/127.0.0.1:1455\/auth\/callback<\/code> \u6355\u83b7\u56de\u8c03<\/li>\n<li>\u5982\u679c\u56de\u8c03\u65e0\u6cd5\u7ed1\u5b9a\uff08\u6216\u4f60\u662f\u5728\u8fdc\u7a0b\/\u65e0\u5934\u73af\u5883\u4e2d\uff09\uff0c\u5219\u7c98\u8d34\u91cd\u5b9a\u5411 URL\/code<\/li>\n<li>\u5728 <code>https:\/\/auth.openai.com\/oauth\/token<\/code> \u4ea4\u6362\u4ee4\u724c<\/li>\n<li>\u4ece\u8bbf\u95ee\u4ee4\u724c\u4e2d\u63d0\u53d6 <code>accountId<\/code> \u5e76\u5b58\u50a8 <code>{ access, refresh, expires, accountId }<\/code><\/li>\n<\/ol>\n<p>\u5411\u5bfc\u8def\u5f84\u4e3a <code>openclaw onboard<\/code> \u2192 \u8ba4\u8bc1\u9009\u62e9 <code>openai-codex<\/code>\u3002<\/p>\n<h2>\u5237\u65b0\u548c\u8fc7\u671f<\/h2>\n<p>\u914d\u7f6e\u6587\u4ef6\u4f1a\u5b58\u50a8\u4e00\u4e2a <code>expires<\/code> \u65f6\u95f4\u6233\u3002<\/p>\n<p>\u5728\u8fd0\u884c\u65f6\uff1a<\/p>\n<ul>\n<li>\u5982\u679c <code>expires<\/code> \u5c1a\u672a\u5230\u671f \u2192 \u4f7f\u7528\u5df2\u5b58\u50a8\u7684\u8bbf\u95ee\u4ee4\u724c<\/li>\n<li>\u5982\u679c\u5df2\u8fc7\u671f \u2192 \u5728\u6587\u4ef6\u9501\u4e0b\u5237\u65b0\uff0c\u5e76\u8986\u76d6\u5df2\u5b58\u50a8\u7684\u51ed\u8bc1<\/li>\n<\/ul>\n<p>\u5237\u65b0\u6d41\u7a0b\u662f\u81ea\u52a8\u7684\uff1b\u901a\u5e38\u4f60\u4e0d\u9700\u8981\u624b\u52a8\u7ba1\u7406\u4ee4\u724c\u3002<\/p>\n<h2>\u591a\u4e2a\u8d26\u6237\uff08\u914d\u7f6e\u6587\u4ef6\uff09+ \u8def\u7531<\/h2>\n<p>\u6709\u4e24\u79cd\u6a21\u5f0f\uff1a<\/p>\n<h3>1\uff09\u63a8\u8350\uff1a\u5206\u79bb\u7684\u667a\u80fd\u4f53<\/h3>\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u201c\u4e2a\u4eba\u201d\u548c\u201c\u5de5\u4f5c\u201d\u6c38\u4e0d\u4ea4\u53c9\uff0c\u8bf7\u4f7f\u7528\u9694\u79bb\u7684\u667a\u80fd\u4f53\uff08\u72ec\u7acb\u7684\u4f1a\u8bdd + \u51ed\u8bc1 + \u5de5\u4f5c\u533a\uff09\uff1a<\/p>\n<p><code>bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\nopenclaw agents add work<br \/>\nopenclaw agents add personal<\/code><\/p>\n<p>\u7136\u540e\u6309\u667a\u80fd\u4f53\u914d\u7f6e\u8ba4\u8bc1\uff08\u4f7f\u7528\u5411\u5bfc\uff09\uff0c\u5e76\u5c06\u804a\u5929\u8def\u7531\u5230\u6b63\u786e\u7684\u667a\u80fd\u4f53\u3002<\/p>\n<h3>2\uff09\u9ad8\u7ea7\uff1a\u5355\u4e2a\u667a\u80fd\u4f53\u4e2d\u7684\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p><code>auth-profiles.json<\/code> \u652f\u6301\u540c\u4e00\u63d0\u4f9b\u5546\u4e0b\u7684\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6 ID\u3002<\/p>\n<p>\u9009\u62e9\u4f7f\u7528\u54ea\u4e2a\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<ul>\n<li>\u901a\u8fc7\u914d\u7f6e\u6392\u5e8f\u5168\u5c40\u9009\u62e9\uff08<code>auth.order<\/code>\uff09<\/li>\n<li>\u901a\u8fc7 <code>\/model ...@&lt;profileId&gt;<\/code> \u6309\u4f1a\u8bdd\u9009\u62e9<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff08\u4f1a\u8bdd\u8986\u76d6\uff09\uff1a<\/p>\n<ul>\n<li><code>\/model Opus@anthropic:work<\/code><\/li>\n<\/ul>\n<p>\u67e5\u770b\u73b0\u6709\u914d\u7f6e\u6587\u4ef6 ID \u7684\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li><code>openclaw channels list --json<\/code>\uff08\u663e\u793a <code>auth[]<\/code>\uff09<\/li>\n<\/ul>\n<p>\u76f8\u5173\u6587\u6863\uff1a<\/p>\n<ul>\n<li><a href=\"\/concepts\/model-failover\">\/concepts\/model-failover<\/a>\uff08\u8f6e\u6362 + \u51b7\u5374\u89c4\u5219\uff09<\/li>\n<li><a href=\"\/tools\/slash-commands\">\/tools\/slash-commands<\/a>\uff08\u547d\u4ee4\u5165\u53e3\uff09<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>OAuth OpenClaw \u901a\u8fc7 OAuth \u652f\u6301\u63d0\u4f9b\u5546\u63d0\u4f9b\u7684\u201c\u8ba2\u9605\u8ba4\u8bc1\u201d\uff0c\u9002\u7528\u4e8e\u652f\u6301\u6b64\u65b9\u5f0f\u7684\u63d0\u4f9b\u5546\uff08\u5c24\u5176\u662f [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":394,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions\/394"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}