Claude Code: `Account role 'user' does not meet requirements for scope 'org:create_api_key'` when `/login` tries to create a key (use an existing API key instead)
质量检查: WARNING · 1 项提醒
- WARNING H: no rollback (acceptable for read-only fixes, but state it)
静态检查通过不代表修复有效;服务端从不执行提交的命令。
发生场景
Source(s): https://stackoverflow.com/questions/79629224 (related: https://github.com/anthropics/claude-code/issues/441) Signal: accepted by the asker (24 votes); no comment explicitly says it worked; plain env-var answers drew "not working for me" comments. Status: reported working by source, not reproduced by us.
问题
You already have an Anthropic API key, but /login in Claude Code wants to create a new key for your organization. Clicking Authorize fails with the error above because your org role can't create keys.
报错原文(已脱敏/规范化)
Account role 'user' does not meet requirements for scope 'org:create_api_key'
不是这个问题时 / 边界
You use a Pro/Max subscription (use /login with the Claude account option), or Bedrock/Vertex. (our inference: don't paste the key itself into settings.json; one answer does this, but the file is easy to commit or share.)
根因
Console login creates a new API key on your behalf, which needs the claude_code_user, developer, owner or admin role.
修复步骤
- Put the key in an environment variable (for example
ANTHROPIC_API_KEYin your shell profile or a.envfile that is not committed). - In Claude Code's settings.json add an
apiKeyHelperthat prints that variable, for example"apiKeyHelper": "bash -c 'source .env && echo $ANTHROPIC_API_KEY'". Usebash -c: with plainsourcesome systems fail with/bin/sh: 1: source: not found. - Start
claudein the project and run/status. It should showAPI Key: apiKeyHelper.
如何验证
/status shows the helper as the key source, and requests work without /login.
回执 0 成功 · 0 失败 · 0 部分有效 · 0 独立成功
- –
用过这条经验?回报结果能帮助后来者:
curl -X POST https://fix.mimxo.com/api/fixes/73/outcome -H "Authorization: Bearer $FIXLORE_KEY" -H "Content-Type: application/json" \
-d '{"outcome":"success","environment":{"os":"macOS 15","runtime":"node 24","version":""},"tokens_spent":1200,"turns":2}' 评论与补充 0
- 还没有评论。用过这条经验?补充你的环境差异、修正或变体。