{"id":115,"date":"2026-03-21T22:47:18","date_gmt":"2026-03-21T14:47:18","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/gateway-authentication\/"},"modified":"2026-03-21T23:29:00","modified_gmt":"2026-03-21T15:29:00","slug":"gateway-authentication","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/gateway-authentication\/","title":{"rendered":"\u8ba4\u8bc1"},"content":{"rendered":"<h1>\u8ba4\u8bc1<\/h1>\n<p>OpenClaw \u652f\u6301\u6a21\u578b\u63d0\u4f9b\u5546\u4f7f\u7528 OAuth \u548c API key\u3002\u5bf9\u4e8e\u59cb\u7ec8\u5728\u7ebf\u7684 Gateway \u7f51\u5173 \u7f51\u5173<br \/>\n\u4e3b\u673a\uff0cAPI key \u901a\u5e38\u662f\u6700\u53ef\u9884\u6d4b\u7684\u9009\u9879\u3002\u5f53\u5b83\u4eec\u4e0e\u4f60\u7684\u63d0\u4f9b\u5546\u8d26\u53f7\u6a21\u578b\u5339\u914d\u65f6\uff0c<br \/>\n\u4e5f\u652f\u6301\u8ba2\u9605\/OAuth \u6d41\u7a0b\u3002<\/p>\n<p>\u5b8c\u6574\u7684 OAuth \u6d41\u7a0b\u548c\u5b58\u50a8\u5e03\u5c40\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/pa.yingzhi8.cn\/?p=99\">\/concepts\/oauth<\/a>\u3002<br \/>\n\u5173\u4e8e\u57fa\u4e8e SecretRef \u7684\u8ba4\u8bc1\uff08<code>env<\/code>\/<code>file<\/code>\/<code>exec<\/code> \u63d0\u4f9b\u5546\uff09\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/pa.yingzhi8.cn\/?p=611\">Secrets Management<\/a>\u3002<br \/>\n\u5173\u4e8e <code>models status --probe<\/code> \u4f7f\u7528\u7684\u51ed\u8bc1\u8d44\u683c\/\u539f\u56e0\u7801\u89c4\u5219\uff0c\u8bf7\u53c2\u9605<br \/>\n<a href=\"https:\/\/pa.yingzhi8.cn\/?p=598\">Auth Credential Semantics<\/a>\u3002<\/p>\n<h2>\u63a8\u8350\u8bbe\u7f6e\uff08API key\uff0c\u4efb\u610f\u63d0\u4f9b\u5546\uff09<\/h2>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u8fd0\u884c\u957f\u671f\u5b58\u6d3b\u7684 Gateway \u7f51\u5173 \u7f51\u5173\uff0c\u8bf7\u5148\u4e3a\u4f60\u9009\u62e9\u7684<br \/>\n\u63d0\u4f9b\u5546\u914d\u7f6e\u4e00\u4e2a API key\u3002<br \/>\n\u5bf9\u4e8e Anthropic\uff0cAPI key \u8ba4\u8bc1\u662f\u66f4\u7a33\u59a5\u7684\u65b9\u5f0f\uff0c\u63a8\u8350\u4f18\u5148\u4e8e<br \/>\n\u8ba2\u9605 setup-token \u8ba4\u8bc1\u3002<\/p>\n<ol>\n<li>\u5728\u4f60\u7684\u63d0\u4f9b\u5546\u63a7\u5236\u53f0\u4e2d\u521b\u5efa\u4e00\u4e2a API key\u3002<\/li>\n<li>\u5c06\u5b83\u653e\u5728 <strong>Gateway \u7f51\u5173 \u7f51\u5173\u4e3b\u673a<\/strong> \u4e0a\uff08\u8fd0\u884c <code>openclaw gateway<\/code> \u7684\u673a\u5668\uff09\u3002<\/li>\n<\/ol>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nexport _API_KEY=&#8221;&#8230;&#8221;<br \/>\nopenclaw models status<\/p>\n<pre><code>\n3. \u5982\u679c Gateway \u901a\u8fc7 systemd\/launchd \u8fd0\u884c\uff0c\u5efa\u8bae\u5c06 key \u653e\u5165\n   `~\/.openclaw\/.env`\uff0c\u8fd9\u6837\u5b88\u62a4\u8fdb\u7a0b\u5c31\u53ef\u4ee5\u8bfb\u53d6\u5b83\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\ncat &gt;&gt; ~\/.openclaw\/.env &lt;&lt;'EOF'\n&lt;PROVIDER&gt;_API_KEY=...\nEOF\n<\/code><\/pre>\n<p>\u7136\u540e\u91cd\u542f\u5b88\u62a4\u8fdb\u7a0b\uff08\u6216\u91cd\u542f\u4f60\u7684 Gateway \u7f51\u5173 \u7f51\u5173\u8fdb\u7a0b\uff09\u5e76\u91cd\u65b0\u68c0\u67e5\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 status<br \/>\nopenclaw doctor<\/p>\n<pre><code>\n\u5982\u679c\u4f60\u4e0d\u60f3\u81ea\u5df1\u7ba1\u7406\u73af\u5883\u53d8\u91cf\uff0c\u8bbe\u7f6e\u5411\u5bfc\u53ef\u4ee5\u4e3a\u5b88\u62a4\u8fdb\u7a0b\u4f7f\u7528\u573a\u666f\u5b58\u50a8\nAPI key\uff1a`openclaw onboard`\u3002\n\n\u6709\u5173\u73af\u5883\u7ee7\u627f\uff08`env.shellEnv`\u3001\n`~\/.openclaw\/.env`\u3001systemd\/launchd\uff09\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 [Help](\/help)\u3002\n\n## Anthropic\uff1asetup-token\uff08\u8ba2\u9605\u8ba4\u8bc1\uff09\n\n\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f Claude \u8ba2\u9605\uff0c\u5219\u652f\u6301 setup-token \u6d41\u7a0b\u3002\u8bf7\u5728\n**Gateway \u7f51\u5173\u4e3b\u673a** \u4e0a\u8fd0\u884c\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nclaude setup-token\n<\/code><\/pre>\n<p>\u7136\u540e\u5c06\u5b83\u7c98\u8d34\u5230 OpenClaw \u4e2d\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 setup-token &#8211;provider anthropic<\/p>\n<pre><code>\n\u5982\u679c token \u662f\u5728\u53e6\u4e00\u53f0\u673a\u5668\u4e0a\u521b\u5efa\u7684\uff0c\u8bf7\u624b\u52a8\u7c98\u8d34\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 paste-token --provider anthropic\n<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u770b\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684 Anthropic \u9519\u8bef\uff1a<\/p>\n<pre><code>This credential is only authorized for use with Claude Code and cannot be used for other API requests.\n<\/code><\/pre>\n<p>\u2026\u2026\u8bf7\u6539\u7528 Anthropic API key\u3002<\/p>\n<p>\n  Anthropic setup-token \u652f\u6301\u4ec5\u662f\u6280\u672f\u517c\u5bb9\u6027\u3002Anthropic \u8fc7\u53bb\u66fe\u963b\u6b62<br \/>\n  Claude Code \u4e4b\u5916\u7684\u67d0\u4e9b\u8ba2\u9605\u7528\u6cd5\u3002\u53ea\u6709\u5728\u4f60\u8ba4\u4e3a\u76f8\u5173\u7b56\u7565\u98ce\u9669\u53ef\u63a5\u53d7\u65f6\u624d\u4f7f\u7528\u5b83\uff0c<br \/>\n  \u5e76\u8bf7\u4f60\u81ea\u884c\u6838\u5b9e Anthropic \u5f53\u524d\u7684\u6761\u6b3e\u3002<br \/>\n<\/\u8b66\u544a><\/p>\n<p>\u624b\u52a8\u8f93\u5165 token\uff08\u4efb\u610f\u63d0\u4f9b\u5546\uff1b\u4f1a\u5199\u5165 <code>auth-profiles.json<\/code> + \u66f4\u65b0\u914d\u7f6e\uff09\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<br \/>\nopenclaw models auth paste-token &#8211;provider openrouter<\/p>\n<pre><code>\n\u9759\u6001\u51ed\u8bc1\u4e5f\u652f\u6301\u51ed\u8bc1\u914d\u7f6e\u6587\u4ef6\u5f15\u7528\uff1a\n\n* `api_key` \u51ed\u8bc1\u53ef\u4ee5\u4f7f\u7528 `keyRef: { source, provider, id }`\n* `token` \u51ed\u8bc1\u53ef\u4ee5\u4f7f\u7528 `tokenRef: { source, provider, id }`\n\n\u9002\u5408\u81ea\u52a8\u5316\u7684\u68c0\u67e5\uff08\u5df2\u8fc7\u671f\/\u7f3a\u5931\u65f6\u9000\u51fa\u7801\u4e3a `1`\uff0c\u5373\u5c06\u8fc7\u671f\u65f6\u4e3a `2`\uff09\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 --check\n<\/code><\/pre>\n<p>\u53ef\u9009\u7684\u8fd0\u7ef4\u811a\u672c\uff08systemd\/Termux\uff09\u8bb0\u5f55\u5728\u8fd9\u91cc\uff1a<br \/>\n<a href=\"https:\/\/pa.yingzhi8.cn\/?p=8\">\/automation\/auth-monitoring<\/a><\/p>\n<blockquote>\n<p><code>claude setup-token<\/code> \u9700\u8981\u4ea4\u4e92\u5f0f TTY\u3002<\/p>\n<\/blockquote>\n<h2>\u68c0\u67e5\u6a21\u578b\u8ba4\u8bc1\u72b6\u6001<\/h2>\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 status<br \/>\nopenclaw doctor<\/p>\n<pre><code>\n## API key \u8f6e\u6362\u884c\u4e3a\uff08Gateway \u7f51\u5173\uff09\n\n\u67d0\u4e9b\u63d0\u4f9b\u5546\u652f\u6301\u5728 API \u8c03\u7528\u89e6\u53d1\u63d0\u4f9b\u5546\u9650\u6d41\u65f6\uff0c\u4f7f\u7528\u66ff\u4ee3 key \u91cd\u8bd5\u8bf7\u6c42\u3002\n\n* \u4f18\u5148\u7ea7\u987a\u5e8f\uff1a\n  * `OPENCLAW_LIVE_&lt;PROVIDER&gt;_KEY`\uff08\u5355\u4e2a\u8986\u76d6\u503c\uff09\n  * `&lt;PROVIDER&gt;_API_KEYS`\n  * `&lt;PROVIDER&gt;_API_KEY`\n  * `&lt;PROVIDER&gt;_API_KEY_*`\n* Google \u63d0\u4f9b\u5546\u8fd8\u5c06 `GOOGLE_API_KEY` \u4f5c\u4e3a\u989d\u5916\u56de\u9000\u9879\u3002\n* \u4f7f\u7528\u524d\u4f1a\u5bf9\u540c\u4e00\u7ec4 key \u5217\u8868\u53bb\u91cd\u3002\n* \u4ec5\u5f53\u51fa\u73b0\u9650\u6d41\u9519\u8bef\u65f6\uff0cOpenClaw \u624d\u4f1a\u4f7f\u7528\u4e0b\u4e00\u4e2a key \u91cd\u8bd5\uff08\u4f8b\u5982\n  `429`\u3001`rate_limit`\u3001`quota`\u3001`resource exhausted`\uff09\u3002\n* \u975e\u9650\u6d41\u9519\u8bef\u4e0d\u4f1a\u4f7f\u7528\u66ff\u4ee3 key \u91cd\u8bd5\u3002\n* \u5982\u679c\u6240\u6709 key \u90fd\u5931\u8d25\uff0c\u5219\u8fd4\u56de\u6700\u540e\u4e00\u6b21\u5c1d\u8bd5\u7684\u6700\u7ec8\u9519\u8bef\u3002\n\n## \u63a7\u5236\u4f7f\u7528\u54ea\u4e2a\u51ed\u8bc1\n\n### \u6bcf\u4e2a\u4f1a\u8bdd\uff08\u804a\u5929\u547d\u4ee4\uff09\n\n\u4f7f\u7528 `\/model &lt;alias-or-id&gt;@&lt;profileId&gt;` \u4e3a\u5f53\u524d\u4f1a\u8bdd\u56fa\u5b9a\u4f7f\u7528\u7279\u5b9a\u7684\u63d0\u4f9b\u5546\u51ed\u8bc1\uff08\u793a\u4f8b\u914d\u7f6e\u6587\u4ef6 id\uff1a`anthropic:default`\u3001`anthropic:work`\uff09\u3002\n\n\u4f7f\u7528 `\/model`\uff08\u6216 `\/model list`\uff09\u67e5\u770b\u7d27\u51d1\u9009\u62e9\u5668\uff1b\u4f7f\u7528 `\/model status` \u67e5\u770b\u5b8c\u6574\u89c6\u56fe\uff08\u5019\u9009\u9879 + \u4e0b\u4e00\u4e2a\u51ed\u8bc1\u914d\u7f6e\u6587\u4ef6\uff0c\u4ee5\u53ca\u5728\u5df2\u914d\u7f6e\u65f6\u663e\u793a\u63d0\u4f9b\u5546\u7aef\u70b9\u8be6\u60c5\uff09\u3002\n\n### \u6bcf\u4e2a\u667a\u80fd\u4f53\uff08CLI \u8986\u76d6\uff09\n\n\u4e3a\u667a\u80fd\u4f53\u8bbe\u7f6e\u663e\u5f0f\u7684\u51ed\u8bc1\u914d\u7f6e\u6587\u4ef6\u987a\u5e8f\u8986\u76d6\uff08\u5b58\u50a8\u5728\u8be5\u667a\u80fd\u4f53\u7684 `auth-profiles.json` \u4e2d\uff09\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 order get --provider anthropic\nopenclaw models auth order set --provider anthropic anthropic:default\nopenclaw models auth order clear --provider anthropic\n<\/code><\/pre>\n<p>\u4f7f\u7528 <code>--agent &lt;id&gt;<\/code> \u6307\u5b9a\u7279\u5b9a\u667a\u80fd\u4f53\uff1b\u7701\u7565\u5b83\u5219\u4f7f\u7528\u5df2\u914d\u7f6e\u7684\u9ed8\u8ba4\u667a\u80fd\u4f53\u3002<\/p>\n<h2>\u6545\u969c\u6392\u9664<\/h2>\n<h3>\u201cNo credentials found\u201d<\/h3>\n<p>\u5982\u679c\u7f3a\u5c11 Anthropic token \u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u5728<br \/>\n<strong>Gateway \u7f51\u5173 \u7f51\u5173\u4e3b\u673a<\/strong> \u4e0a\u8fd0\u884c <code>claude setup-token<\/code>\uff0c\u7136\u540e\u91cd\u65b0\u68c0\u67e5\uff1a<\/p>\n<p><code>bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\nopenclaw models status<\/code><\/p>\n<h3>Token \u5373\u5c06\u8fc7\u671f\/\u5df2\u8fc7\u671f<\/h3>\n<p>\u8fd0\u884c <code>openclaw models status<\/code> \u4ee5\u786e\u8ba4\u54ea\u4e2a\u914d\u7f6e\u6587\u4ef6\u5373\u5c06\u8fc7\u671f\u3002\u5982\u679c\u8be5\u914d\u7f6e\u6587\u4ef6<br \/>\n\u7f3a\u5931\uff0c\u8bf7\u91cd\u65b0\u8fd0\u884c <code>claude setup-token<\/code> \u5e76\u518d\u6b21\u7c98\u8d34 token\u3002<\/p>\n<h2>\u8981\u6c42<\/h2>\n<ul>\n<li>Anthropic \u8ba2\u9605\u8d26\u53f7\uff08\u7528\u4e8e <code>claude setup-token<\/code>\uff09<\/li>\n<li>\u5df2\u5b89\u88c5 Claude Code CLI\uff08<code>claude<\/code> \u547d\u4ee4\u53ef\u7528\uff09<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u8ba4\u8bc1 OpenClaw \u652f\u6301\u6a21\u578b\u63d0\u4f9b\u5546\u4f7f\u7528 OAuth \u548c API key\u3002\u5bf9\u4e8e\u59cb\u7ec8\u5728\u7ebf\u7684 Gateway \u7f51 [&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-115","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/115","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=115"}],"version-history":[{"count":2,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":828,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/115\/revisions\/828"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}