Skip to content

No longer able to use API token for auth #13744

@thexeos

Description

@thexeos

What versions & operating system are you using?

System:
OS: Windows 11
Binaries:
Node: 22.14.0
npm: 11.10.1
npmPackages:
@cloudflare/vite-plugin: ^1.34.0 => 1.34.0
wrangler: ^4.86.0 => 4.86.0

Please provide a link to a minimal reproduction

N/A

Describe the Bug

> wrangler whoami
 ⛅️ wrangler 4.86.0
───────────────────
Getting User settings...
X [ERROR] Failed to fetch auth token: 400 Bad Request

X [ERROR] You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth.

X [ERROR] Not logged in.

I tried:

  • Account API Tokens (this one used to work about a week ago - its status shows as Active and it has no expiration date set)
  • User API Tokens
  • Global API Key

I can't use OAuth since I need to be able to interact with multiple different Cloudflare accounts and Wrangler does not work like that.

It used to work with just CLOUDFLARE_API_TOKEN in .env but I saw warning for missing .env.local so I also tried to use that and I've added CLOUDFLARE_ACCOUNT_ID to both files - but none of it works any more.

Please provide any relevant error logs

--- 2026-04-29T22:26:07.907Z debug
🪵  Writing logs to "wrangler-2026-04-29_22-26-07_701.log"
---

--- 2026-04-29T22:26:07.907Z log

 ⛅️ wrangler 4.86.0
───────────────────
---

--- 2026-04-29T22:26:07.916Z debug
Metrics dispatcher: Posting data {/* redacted */}
---

--- 2026-04-29T22:26:07.933Z log
Getting User settings...
---

--- 2026-04-29T22:26:07.935Z debug
fetching auth token grant_type=refresh_token&refresh_token=/* redacted */&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7
---

--- 2026-04-29T22:26:07.935Z debug
Checking if domain has Access enabled: dash.cloudflare.com
---

--- 2026-04-29T22:26:07.935Z debug
Access switch not cached for: dash.cloudflare.com
---

--- 2026-04-29T22:26:08.078Z debug
Caching access switch for: dash.cloudflare.com
---

--- 2026-04-29T22:26:08.078Z debug
Fetching auth token from https://dash.cloudflare.com/oauth2/token
---

--- 2026-04-29T22:26:08.731Z error
X [ERROR] Failed to fetch auth token: 400 Bad Request


---

--- 2026-04-29T22:26:08.735Z error
X [ERROR] You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth.


---

--- 2026-04-29T22:26:08.736Z debug
Metrics dispatcher: Posting data {/* redacted */}
---

--- 2026-04-29T22:26:08.737Z log

---

--- 2026-04-29T22:26:08.738Z error
X [ERROR] Not logged in.


---

--- 2026-04-29T22:26:08.739Z debug
Error: Not logged in.
    at requireLoggedIn (...wrangler\wrangler-dist\cli.js:132674:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async performApiFetch (...wrangler\wrangler-dist\cli.js:132537:3)
    at async fetchInternal (...wrangler\wrangler-dist\cli.js:132579:20)
    at async fetchResult (...wrangler\wrangler-dist\cli.js:132827:47)
    at async getTokenType (...wrangler\wrangler-dist\cli.js:299371:5)
    at async getAuthType (...wrangler\wrangler-dist\cli.js:299362:21)
    at async getUserInfo (...wrangler\wrangler-dist\cli.js:299344:20)
    at async whoami (...wrangler\wrangler-dist\cli.js:299204:16)
    at async Object.handler (...wrangler\wrangler-dist\cli.js:299558:9)
---

Metadata

Metadata

Labels

awaiting reporter responseNeeds clarification or followup from OPwranglerRelating to the Wrangler CLI tool

Type

No fields configured for Bug.

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions