question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 BUG: Wrangler fails token authorization when ID is not provided

See original GitHub issue

What version of Wrangler are you using?

2.0.29 - 2.1.4

What operating system are you using?

Windows and Linux

Describe the Bug

Create a new token for with the following permissions:

User > User Details > Read Account > Account Settings > Read Account > Cloudflare Pages > Edit

Now run CLOUDFLARE_API_TOKEN=<token> wrangler pages publish <folder> --project-name <project>

You will see an error:

Failed to automatically retrieve account IDs for the logged in user.
  You may have incorrect permissions on your API token. You can skip this account check by adding an account_id in your wrangler.toml, or by setting the value of CLOUDFLARE_ACCOUNT_ID. 

Since my token is associated with a single account, wrangler should not ask for CLOUDFLARE_ACCOUNT_ID to log me in.

This is in part a security issue, as a compromised token can be invalidated but a compromised account ID cannot!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
domnantascommented, Oct 13, 2022

Yep, that should fix the issue. And CI/CD docs section got an update with a very clear explanation 🎉

1reaction
caasscommented, Oct 13, 2022

I’ve opened a PR internally to update the “Edit Cloudflare Workers” template to include the “User Memberships: Read” permission, and opened https://github.com/cloudflare/cloudflare-docs/pull/6273 to update the docs once the internal PR is merged. It seems to me like once those go live that should be enough to solve this problem, or am I misunderstanding?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Primary Refresh Token (PRT) and Azure AD - Microsoft Learn
The device ID claim is used to determine authorization for Conditional Access based on device state or compliance. Session key: The session key ......
Read more >
Deprecations · Cloudflare Workers docs
The wrangler config command is no longer available for authenticating via an API token. Use wrangler login / wrangler logout to manage OAuth ......
Read more >
Tokens & Authentication - React chat - GetStream.io
Stream uses JWT (JSON Web Tokens) to authenticate chat users, enabling them to login. Knowing whether a user is authorized to perform certain...
Read more >
JWT Auth – WordPress JSON Web Token Authentication
WordPress JSON Web Token Authentication allows you to do REST API authentication via token. It is a simple, non-complex, and easy to use....
Read more >
Kong JWT Signer plugin
The plugin refers to tokens as an access token and channel token. ... When authentication or authorization fails, or there is an unexpected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found