Answer: Both `claude -p ... --environment` and `claude -p ... --cloud` authenticate with a claude.ai OAuth token; API keys such as `sk-ant-xxxxx` aren't accepted. For ephemeral CI runners there is no long-lived CI token today, so you should run `claude -p` from a long-lived CI host instead. Status: Confirmed Entry: tool/claude-code/admin-and-enterprise/authenticate-from-ci Revision: 3 Digest: sha256:cc2a9c85c9b2bc99 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:05:43Z Last changed: 2026-11-20T12:25:07Z (Ephemeral runner recommendation: — → long-lived CI host) Last verified: 2026-11-20T12:25:07Z Next check: 2026-11-21T12:25:07Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Unit | Source | As of Authentication method | claude.ai OAuth token | | [1] | 2026-11-20 API keys not accepted | sk-ant-xxxxx | | [1] | 2026-11-20 Refresh-token grant cap | 30 days | days | [1] | 2026-11-20 Cloud-session scope cap | 30 days | days | [1] | 2026-11-20 setup-token validity | one-year inference-only token | | [1] | 2026-11-20 Ephemeral runner recommendation | long-lived CI host | | [1] | 2026-11-20 Sources: [1] Anthropic. "Test self-hosted environments end to end". https://code.claude.com/docs/en/self-hosted-environments-testing.md Role: primary. Accessed: 2026-11-20T12:25:07Z Quote: "authenticate with a claude.ai OAuth token" (Supports: Authentication method) Quote: "API keys, such as `sk-ant-xxxxx`, aren't accepted for either call" (Supports: API keys not accepted) Quote: "the underlying refresh-token grant is capped at 30 days from the initial login" (Supports: Refresh-token grant cap) Quote: "is capped server-side at 30 days" (Supports: Cloud-session scope cap) Quote: "`claude setup-token`, which mints a one-year inference-only token, doesn't cover it" (Supports: setup-token validity) Quote: "Run `claude -p` from a [long-lived CI host](#long-lived-ci-host) instead." (Supports: Ephemeral runner recommendation) Published: 2026-11-20T03:48:50Z Snapshot SHA-256: b3c6e8a5d7872e279c8228218555bd8ec42232c995093c21a513796cc9a0d8d7 (captured 2026-11-20T12:25:07Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:25:07Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:25:07Z Last attempt: 2026-11-20T12:25:07Z Notes and limitations: Extracted automatically from a single official source (section "Authenticate from CI"). Related: https://latestn.com/tool/claude-code/admin-and-enterprise/available-metrics-events What metrics and events does Claude Code export via OpenTelemetry? https://latestn.com/tool/claude-code/admin-and-enterprise/aws-gateway-architecture What AWS infrastructure does Claude apps gateway require to deploy on ECS Fargate or EKS? https://latestn.com/tool/claude-code/admin-and-enterprise/block-code-mode-org How do I block Code Mode for my organization in Claude Code? https://latestn.com/tool/claude-code/admin-and-enterprise/analytics-access-team-enterprise Who can access the Claude Code analytics dashboard for Team and Enterprise plans? https://latestn.com/tool/claude-code/admin-and-enterprise/api-customer-analytics Where can API customers view Claude Code usage and spend analytics? https://latestn.com/tool/claude-code/admin-and-enterprise/audit-plugin-installs How do I audit which plugins are installed across my organization in Claude Code? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:25:07Z | changed | Ephemeral runner recommendation: — → long-lived CI host | [1] 2026-11-20T12:25:07Z | changed | setup-token validity: — → one-year inference-only token | [1] 2026-11-20T12:25:07Z | changed | Cloud-session scope cap: — → 30 days | [1] 2026-11-20T12:25:07Z | changed | Refresh-token grant cap: — → 30 days | [1] 2026-11-20T12:25:07Z | changed | Authentication method: — → claude.ai OAuth token | [1] 2026-11-20T12:25:07Z | changed | cloud-session scope cap: 30 days → — | [1] 2026-11-20T12:25:07Z | changed | ephemeral runner token: There is no long-lived CI token for this today → — | [1] 2026-11-20T12:25:07Z | changed | re-login interval: every 30 days → — | [1] 2026-11-20T12:25:07Z | changed | refresh-token cap: 30 days → — | [1] 2026-11-20T12:25:07Z | changed | login command: claude auth login → — | [1] 2026-11-20T12:25:07Z | changed | authentication method: claude.ai OAuth token → — | [1] 2026-11-17T12:31:02Z | changed | cloud-session scope cap: — → 30 days | [1] 2026-11-17T12:31:02Z | changed | ephemeral runner token: — → There is no long-lived CI token for this today | [1] 2026-11-17T12:31:02Z | changed | re-login interval: — → every 30 days | [1] 2026-11-17T12:31:02Z | changed | refresh-token cap: — → 30 days | [1] 2026-11-17T12:31:02Z | changed | login command: — → claude auth login | [1] 2026-11-17T12:31:02Z | changed | API keys not accepted: — → sk-ant-xxxxx | [1] 2026-11-17T12:31:02Z | changed | authentication method: — → claude.ai OAuth token | [1] 2026-11-17T12:31:02Z | changed | Accepted auth type: claude.ai OAuth token → — | [1] 2026-11-17T12:31:02Z | changed | Scope cap: 30 days → — | [1] 2026-11-17T12:31:02Z | changed | Ephemeral runner env vars: CLAUDE_CODE_OAUTH_REFRESH_TOKEN → — | [1] 2026-11-17T12:31:02Z | changed | Refresh grant cap: 30 days → — | [1] 2026-11-17T12:31:02Z | changed | Long-lived host method: claude auth login → — | [1] 2026-11-13T03:05:43Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/admin-and-enterprise/authenticate-from-ci/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/admin-and-enterprise/authenticate-from-ci POST: https://latestn.com/dispute/tool/claude-code/admin-and-enterprise/authenticate-from-ci with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/admin-and-enterprise/authenticate-from-ci?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I authenticate Claude Code from CI when testing self-hosted environments? Revision 3, last verified 2026-11-20T12:25:07Z. https://latestn.com/tool/claude-code/admin-and-enterprise/authenticate-from-ci (accessed 2026-11-21T09:56:54Z). @misc{LatestN_tool_claude_code_admin_and_enterprise_authenticate_from_ci_r3, title = {How do I authenticate Claude Code from CI when testing self-hosted environments?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/admin-and-enterprise/authenticate-from-ci}}, note = {Revision 3; digest sha256:cc2a9c85c9b2bc99; last verified 2026-11-20T12:25:07Z; accessed 2026-11-21T09:56:54Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/admin-and-enterprise/authenticate-from-ci