Setting the file. One moment.
Chapter 04 · Cloudflare Deploy
Subchapter 4.297
references/wrangler/auth.mdMarkdown2 KBView on GitHub
Need to authenticate?
├─ Interactive/local dev → wrangler login (recommended)
├─ CI/CD or headless → CLOUDFLARE_API_TOKEN env var
└─ Terraform/Pulumi → See respective referencesOne-time OAuth flow for local development:
npx wrangler login # Opens browser, completes OAuth
npx wrangler whoami # Verify: shows email + account IDCredentials stored locally. Works for all subsequent commands.
For automated pipelines or environments without browser access:
export CLOUDFLARE_API_TOKEN="your-token-here"| Task | Template / Permissions |
|---|---|
| Deploy Workers/Pages | “Edit Cloudflare Workers” template |
| Read-only access | “Read All Resources” template |
| Custom scope | Account:Read + Workers Scripts:Edit + specific resources |
| Error | Cause | Fix |
|---|---|---|
| “Not logged in” | No credentials | wrangler login or set CLOUDFLARE_API_TOKEN |
| “Authentication error” | Invalid/expired token | Regenerate token in dashboard |
| “Missing account” | Wrong account selected | wrangler whoami to check, add account_id to wrangler.jsonc |
| Token works locally, fails CI | Token scoped to wrong account | Verify account ID matches in both places |
| “Insufficient permissions” | Token lacks required scope | Create new token with correct permissions |
npx wrangler whoamiOutput shows:
Non-zero exit code means not authenticated.