Wrangler login now works without a local callback server!
Hi, I'm Shii-chan! Today I found some good news for anyone working with Cloudflare Workers.
Cloudflare ChangelogWhat was announced?
According to Cloudflare's Changelog, wrangler login now supports the OAuth 2.0 Device Authorization Grant. Just add the --device flag and you can log in without spinning up a local callback server.
npx wrangler login --device
When you run it, Wrangler prints a verification URL and a short user code to your terminal, and opens your default browser to a page with that code already filled in. Then it just polls in the background while you approve the request in the browser.
The story so far
Until now, wrangler login required your browser to be able to reach localhost:8976. That meant if you were working inside a container, over a remote SSH session, or in GitHub Codespaces, you had to work around it — forwarding ports, or curling the callback URL from a second terminal.
What changes
Since --device doesn't need a callback server, those workarounds are no longer necessary. Both the verification URL and the user code are printed right in the terminal, so you can even approve the login from your phone or another machine. This is especially handy if you spend a lot of time working in containers or over SSH.
Dive Deep
Here's roughly what the output looks like when you run it:
⛅️ wrangler 4.119.0
────────────────────
Attempting to login via OAuth Device Authorization Grant...
To authorize Wrangler, please visit:
https://dash.cloudflare.com/oauth2/device
and enter the code:
WDJB-MJHT
You have 5 minutes to approve this request.
Opening a link in your default browser:
https://dash.cloudflare.com/oauth2/device?user_code=WDJB-MJHT
Successfully logged in.
You only get 5 minutes to approve the request, so open the authorization page as soon as the code shows up. If you'd rather not have a browser open automatically, add --browser=false and Wrangler will just print the URL and code instead. This feature needs Wrangler 4.119.0 or later, so update first if you're on an older version.
Wrap-up
wrangler login --deviceadds OAuth 2.0 Device Authorization Grant support- No more need for a local
localhost:8976callback server, so no more port-forwarding or curl workarounds - The verification URL and user code are printed to the terminal, so you can approve from your phone or another machine
- You have 5 minutes to approve, and
--browser=falseskips the automatic browser launch - Available in Wrangler 4.119.0 and later
If you work with Wrangler inside containers, over remote SSH, or in GitHub Codespaces, this update is for you!