{"id":1685,"date":"2026-06-07T16:07:43","date_gmt":"2026-06-07T08:07:43","guid":{"rendered":"https:\/\/www.imaseo.com\/blog\/?p=1685"},"modified":"2026-06-02T15:26:11","modified_gmt":"2026-06-02T07:26:11","slug":"codex-config-login-troubleshooting","status":"publish","type":"post","link":"https:\/\/www.imaseo.com\/blog\/ai-tools\/codex-config-login-troubleshooting","title":{"rendered":"Codex \u914d\u7f6e\u540e\u8fd8\u63d0\u793a\u767b\u5f55\u600e\u4e48\u529e\uff1f\u4ece auth.json \u5230\u6700\u5c0f\u8bf7\u6c42\u600e\u4e48\u6392\u67e5\uff1f"},"content":{"rendered":"<p><strong>Codex \u914d\u7f6e\u540e\u8fd8\u63d0\u793a\u767b\u5f55\u600e\u4e48\u529e\uff1f\u4ece auth.json \u5230\u6700\u5c0f\u8bf7\u6c42\u7684\u5b8c\u6574\u6392\u67e5\u6559\u7a0b<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u6309\u7167\u6559\u7a0b\u914d\u7f6e\u5b8c Codex\uff0c\u5374\u4f9d\u7136\u53cd\u590d\u5f39\u51fa\u201c\u8bf7\u767b\u5f55\u201d\u6216\u63d0\u793a <code>401 Unauthorized<\/code>\uff0c\u522b\u614c\u3002\u8fd9\u901a\u5e38\u4e0d\u662f\u4ee3\u7801\u95ee\u9898\uff0c\u800c\u662f\u914d\u7f6e\u6587\u4ef6\u3001\u8bf7\u6c42\u5934\u6216\u73af\u5883\u6ca1\u6709\u5f7b\u5e95\u5237\u65b0\u5bfc\u81f4\u7684\u3002\u672c\u6587\u4ece <code>auth.json<\/code>\u3001<code>config.toml<\/code>\u3001Base URL \u5230\u6700\u5c0f\u8bf7\u6c42\uff0c\u4e00\u6b65\u6b65\u6559\u4f60\u7cfb\u7edf\u6027\u6392\u67e5\uff0c10 \u5206\u949f\u5185\u5e2e\u4f60\u5b9a\u4f4d\u5e76\u89e3\u51b3\u767b\u5f55\u95ee\u9898\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u914d\u7f6e\u5b8c Codex \u8fd8\u662f\u63d0\u793a\u767b\u5f55\uff1f<\/h3>\n<p>Codex \u5728\u542f\u52a8\u65f6\u4f1a\u6309\u4ee5\u4e0b\u987a\u5e8f\u8bfb\u53d6\u914d\u7f6e\uff1a<\/p>\n<ol>\n<li><code>~\/.codex\/auth.json<\/code>\uff08\u5b58\u50a8 API Key\uff09<\/li>\n<li><code>~\/.codex\/config.toml<\/code>\uff08\u6a21\u578b\u3001Base URL \u7b49\u6838\u5fc3\u914d\u7f6e\uff09<\/li>\n<li>\u73af\u5883\u53d8\u91cf\u548c\u547d\u4ee4\u884c\u53c2\u6570<\/li>\n<\/ol>\n<p>\u53ea\u8981\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u73af\u8282\u51fa\u95ee\u9898\uff0c\u5b83\u5c31\u4f1a\u56de\u9000\u5230\u5b98\u65b9\u767b\u5f55\u903b\u8f91\uff0c\u4ece\u800c\u51fa\u73b0\u53cd\u590d\u63d0\u793a\u767b\u5f55\u7684\u60c5\u51b5\u3002<\/p>\n<h3>\u7b2c\u4e00\u6b65\uff1a\u68c0\u67e5 auth.json \u662f\u5426\u6b63\u786e<\/h3>\n<p>\u8fd9\u662f\u6700\u5e38\u89c1\u7684\u95ee\u9898\u70b9\u3002<\/p>\n<p>\u6b63\u786e\u8def\u5f84\uff08\u4e09\u5e73\u53f0\u901a\u7528\uff09\uff1a<br \/>\n&#8211; Windows: <code>C:\\Users\\\u4f60\u7684\u7528\u6237\u540d\\.codex\\auth.json<\/code><br \/>\n&#8211; macOS \/ Linux: <code>~\/.codex\/auth.json<\/code><\/p>\n<p><strong>\u6b63\u786e\u5199\u6cd5\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"language-json\">{\n  &quot;api_key&quot;: &quot;sk-XXXXXXXXXXXXXXXXXXXXXXXX&quot;\n}\n<\/code><\/pre>\n<p><strong>\u5e38\u89c1\u9519\u8bef\u53ca\u6392\u67e5\u65b9\u6cd5\uff1a<\/strong><br \/>\n&#8211; Key \u524d\u540e\u6709\u7a7a\u683c\u6216\u6362\u884c<br \/>\n&#8211; \u590d\u5236\u4e86 <code>Bearer sk-...<\/code> \u800c\u4e0d\u662f\u7eaf key<br \/>\n&#8211; \u6587\u4ef6\u540d\u5199\u6210\u4e86 <code>auth.json.txt<\/code><br \/>\n&#8211; \u6587\u4ef6\u7f16\u7801\u4e0d\u662f UTF-8<\/p>\n<p><strong>\u5feb\u901f\u9a8c\u8bc1\u547d\u4ee4\uff1a<\/strong><\/p>\n<pre><code class=\"language-bash\">cat ~\/.codex\/auth.json\n<\/code><\/pre>\n<p>\u786e\u8ba4 key \u6b63\u786e\u540e\uff0c\u7ee7\u7eed\u4e0b\u4e00\u6b65\u3002<\/p>\n<h3>\u7b2c\u4e8c\u6b65\uff1a\u6b63\u786e\u914d\u7f6e config.toml\uff08\u6700\u5bb9\u6613\u5ffd\u7565\uff09<\/h3>\n<p>\u5f88\u591a\u4eba\u5728\u6539\u5b8c <code>auth.json<\/code> \u540e\u5fd8\u8bb0\u540c\u6b65\u4fee\u6539 <code>config.toml<\/code>\uff0c\u5bfc\u81f4\u914d\u7f6e\u4e0d\u751f\u6548\u3002<\/p>\n<p><strong>\u63a8\u8350\u7684\u6700\u5c0f\u53ef\u7528\u914d\u7f6e\uff1a<\/strong><\/p>\n<pre><code class=\"language-toml\">base_url = &quot;https:\/\/api.token173.com\/v1&quot;\nmodel = &quot;gpt-4o-mini&quot;\n\nauth\nprovider = &quot;bearer&quot;\napi_key = &quot;sk-XXXXXXXXXXXXXXXXXXXXXXXX&quot;\n<\/code><\/pre>\n<p><strong>\u91cd\u70b9\u6ce8\u610f\uff1a<\/strong><br \/>\n&#8211; <code>base_url<\/code> \u5fc5\u987b\u4ee5 <code>\/v1<\/code> \u7ed3\u5c3e<br \/>\n&#8211; \u4e0d\u8981\u4f7f\u7528\u5b98\u65b9 <code>https:\/\/api.openai.com\/v1<\/code><br \/>\n&#8211; \u5982\u679c\u4f7f\u7528\u56fd\u5185\u4e2d\u8f6c\u670d\u52a1\uff0c\u5fc5\u987b\u786e\u8ba4\u5bf9\u65b9\u652f\u6301 <code>\/v1\/chat\/completions<\/code> \u8def\u7531<\/p>\n<h3>\u7b2c\u4e09\u6b65\uff1a\u5b8c\u5168\u91cd\u542f\u7ec8\u7aef\u548c VSCode<\/h3>\n<p>\u8fd9\u662f\u5f88\u591a\u4eba\u7684\u201c\u9690\u5f62\u5751\u201d\u3002<\/p>\n<p>\u914d\u7f6e\u6539\u5b8c\u540e\uff0c\u65e7\u7684 Codex \u8fdb\u7a0b\u4ecd\u7136\u8fd0\u884c\u5728\u5185\u5b58\u4e2d\uff0c\u4f7f\u7528\u7684\u662f\u65e7\u914d\u7f6e\u3002<strong>\u5fc5\u987b\u5b8c\u5168\u91cd\u542f<\/strong>\uff1a<\/p>\n<ol>\n<li>\u5173\u95ed\u5f53\u524d\u7ec8\u7aef\u7a97\u53e3<\/li>\n<li>\u5f7b\u5e95\u5173\u95ed VSCode\uff08\u5305\u62ec\u6240\u6709\u5b9e\u4f8b\uff09<\/li>\n<li>\u91cd\u65b0\u6253\u5f00\u7ec8\u7aef<\/li>\n<li>\u6267\u884c <code>codex --version<\/code> \u9a8c\u8bc1<\/li>\n<\/ol>\n<h3>\u7b2c\u56db\u6b65\uff1a\u7528\u6700\u5c0f\u8bf7\u6c42\u9a8c\u8bc1\u662f\u5426\u771f\u6b63\u6253\u901a<\/h3>\n<p>\u8fd9\u662f\u6700\u5173\u952e\u7684\u4e00\u6b65\u2014\u2014<strong>\u6700\u5c0f\u5316\u6d4b\u8bd5\u8bf7\u6c42<\/strong>\u3002<\/p>\n<p>\u5728\u7ec8\u7aef\u76f4\u63a5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">codex --model gpt-4o-mini &quot;\u8f93\u51fa\u4e00\u4e2a hello world \u51fd\u6570&quot;\n<\/code><\/pre>\n<p>\u6216\u8005\u4f7f\u7528 curl \u505a\u6700\u7eaf\u7cb9\u7684\u6d4b\u8bd5\uff08\u63a8\u8350\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\">curl -X POST https:\/\/api.token173.com\/v1\/chat\/completions \\\n  -H &quot;Authorization: Bearer sk-XXXXXXXXXXXXXXXXXXXXXXXX&quot; \\\n  -H &quot;Content-Type: application\/json&quot; \\\n  -d '{\n    &quot;model&quot;: &quot;gpt-4o-mini&quot;,\n    &quot;messages&quot;: {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Say hello&quot;},\n    &quot;max_tokens&quot;: 50\n  }'\n<\/code><\/pre>\n<p>\u5982\u679c curl \u80fd\u6b63\u5e38\u8fd4\u56de\uff0c\u8bf4\u660e API \u672c\u8eab\u662f\u901a\u7684\uff0c\u95ee\u9898\u51fa\u5728 Codex \u7684\u914d\u7f6e\u52a0\u8f7d\u903b\u8f91\u4e0a\u3002<\/p>\n<h3>\u5e38\u89c1\u95ee\u9898\u5feb\u901f\u6392\u67e5\u8868<\/h3>\n<div style=\"overflow-x:auto; -webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%; border-collapse:collapse; border:1px solid ddd; margin:20px 0;\">\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\"ead style=\"background-color:f7f7f7; font-weight:bold;\">\n<tr>\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\" style=\"background-color:f7f7f7; font-weight:bold;\">\u95ee\u9898\u73b0\u8c61<\/th>\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\" style=\"background-color:f7f7f7; font-weight:bold;\">\u53ef\u80fd\u539f\u56e0<\/th>\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\" style=\"background-color:f7f7f7; font-weight:bold;\">\u89e3\u51b3\u65b9\u6cd5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u59cb\u7ec8\u63d0\u793a\u767b\u5f55<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">auth.json \u672a\u52a0\u8f7d<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u68c0\u67e5\u6587\u4ef6\u8def\u5f84\u548c\u5185\u5bb9\uff0c\u91cd\u65b0\u542f\u52a8\u7ec8\u7aef<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">401 Unauthorized<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">Key \u9519\u8bef\u6216 Base URL \u9519\u8bef<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u9a8c\u8bc1 Key \u5b8c\u6574\u6027\uff0c\u786e\u8ba4 Base URL \u4ee5 \/v1 \u7ed3\u5c3e<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u914d\u7f6e\u4fee\u6539\u540e\u4e0d\u751f\u6548<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u7ec8\u7aef\u8fdb\u7a0b\u672a\u91cd\u542f<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u5f7b\u5e95\u5173\u95ed\u7ec8\u7aef\u548c VSCode \u540e\u91cd\u8bd5<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u80fd\u7528\u4f46\u4e00\u76f4\u63d0\u793a\u767b\u5f55<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">config.toml \u4e2d auth \u914d\u7f6e\u7f3a\u5931<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u8865\u5145 auth \u533a\u5757<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u5207\u6362\u6a21\u578b\u540e\u4ecd\u62a5\u9519<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u65e7\u4f1a\u8bdd\u672a\u5237\u65b0<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u65b0\u5efa\u4e00\u4e2a\u7ec8\u7aef\u4f1a\u8bdd\u6216\u65b0\u5bf9\u8bdd<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3>\u4ec0\u4e48\u65f6\u5019\u8be5\u8003\u8651\u66f4\u6362\u63a5\u5165\u65b9\u5f0f\uff1f<\/h3>\n<p>\u5982\u679c\u4f60\u53ea\u662f\u60f3\u5feb\u901f\u8dd1\u901a\u539f\u578b\uff0c\u5efa\u8bae\u4f18\u5148\u4f7f\u7528\u7a33\u5b9a\u4e14\u6587\u6863\u6e05\u6670\u7684\u4e2d\u8f6c\u670d\u52a1\u3002\u5148\u628a\u6700\u5c0f\u8bf7\u6c42\u6253\u901a\uff0c\u518d\u51b3\u5b9a\u662f\u5426\u957f\u671f\u4f7f\u7528\u3002<\/p>\n<p>\u76ee\u524d\u5f88\u591a\u5f00\u53d1\u8005\u5728\u521d\u671f\u6d4b\u8bd5\u9636\u6bb5\u4f1a\u9009\u62e9 <strong>AI\u9a7f\u7ad9<\/strong>\uff08https:\/\/apivibe.cn\/register?aff=E7yk\uff09\uff0c\u5b83\u7684\u63a7\u5236\u53f0\u80fd\u6e05\u6670\u5c55\u793a\u53ef\u7528\u7684 Base URL \u548c\u6a21\u578b\u5217\u8868\uff0c\u907f\u514d\u4e00\u5f00\u59cb\u5c31\u88ab\u590d\u6742\u7684\u914d\u7f6e\u4fe1\u606f\u641e\u6655\u3002<\/p>\n<h3>\u603b\u7ed3\uff1a\u6700\u5c0f\u63a5\u5165\u94fe\u8def\u56db\u6b65\u6cd5<\/h3>\n<ol>\n<li><strong>\u5199\u5bf9 auth.json<\/strong>\uff08\u7eaf Key\uff0c\u65e0\u591a\u4f59\u5b57\u7b26\uff09<\/li>\n<li><strong>\u914d\u597d config.toml<\/strong>\uff08\u6b63\u786e\u7684 base_url + \/v1\uff09<\/li>\n<li><strong>\u5f7b\u5e95\u91cd\u542f\u7ec8\u7aef\u548c\u7f16\u8f91\u5668<\/strong><\/li>\n<li><strong>\u7528 curl \u6216 codex \u6700\u5c0f\u547d\u4ee4\u9a8c\u8bc1<\/strong><\/li>\n<\/ol>\n<p>\u628a\u8fd9\u56db\u4ef6\u4e8b\u8dd1\u901a\u540e\uff0c90% \u7684\u201c\u914d\u7f6e\u540e\u8fd8\u63d0\u793a\u767b\u5f55\u201d\u95ee\u9898\u90fd\u80fd\u89e3\u51b3\u3002<\/p>\n<hr \/>\n<p><strong>\u73b0\u5728\u884c\u52a8\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u5f53\u524d\u6b63\u5361\u5728 Codex \u53cd\u590d\u8981\u6c42\u767b\u5f55\uff0c\u53ef\u4ee5\u76f4\u63a5\u6309\u7167\u4e0a\u9762\u7684\u987a\u5e8f\u4ece <code>auth.json<\/code> \u5f00\u59cb\u6392\u67e5\u3002\u6392\u67e5\u5b8c\u540e\uff0c\u5efa\u8bae\u53bb <strong>AI\u9a7f\u7ad9<\/strong>\uff08https:\/\/apivibe.cn\/register?aff=E7yk\uff09\u770b\u4e00\u773c\u6700\u65b0\u7684\u53ef\u7528\u5165\u53e3\u548c\u63a7\u5236\u53f0\u4fe1\u606f\uff0c\u5148\u7528\u5c0f\u989d\u5ea6\u8dd1\u901a\u4e00\u6761\u94fe\u8def\uff0c\u518d\u51b3\u5b9a\u662f\u5426\u7eb3\u5165\u6b63\u5f0f\u5f00\u53d1\u6d41\u7a0b\u3002<\/p>\n<p>\u5148\u8dd1\u901a\uff0c\u518d\u4f18\u5316\uff0c\u8fd9\u662f\u4f7f\u7528 Codex \u6700\u7a33\u7684\u8def\u5f84\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Codex \u914d\u7f6e\u540e\u8fd8\u63d0\u793a\u767b\u5f55\u600e\u4e48\u529e\uff1f\u4ece auth.json \u5230\u6700\u5c0f\u8bf7\u6c42\u7684\u5b8c\u6574\u6392\u67e5\u6559\u7a0b \u5982\u679c\u4f60\u6309\u7167\u6559\u7a0b\u914d\u7f6e\u5b8c Codex\uff0c\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1685","post","type-post","status-publish","format-standard","hentry","category-ai-tools"],"_links":{"self":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts\/1685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/comments?post=1685"}],"version-history":[{"count":1,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts\/1685\/revisions"}],"predecessor-version":[{"id":1686,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts\/1685\/revisions\/1686"}],"wp:attachment":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/media?parent=1685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/categories?post=1685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/tags?post=1685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}