๐ BUG: wrangler user (read) scope missing after wrangler login --scopes
Which Cloudflare product(s) does this pertain to?
Wrangler core
What version(s) of the tool(s) are you using?
3.22.1
What version of Node are you using?
21.2.0
What operating system are you using?
Mac
Describe the Bug
It's possible to get into an invalid state where one is missing the user (read) scope in Wrangler. Consider the example below.
Steps to repro
npx wrangler@latest logoutnpx wrangler@latest login --scopes "ai:read"(or any other specific scope)- Complete the oAuth dialog
npx wrangler@latest r2 bucket create "foo"(or any other wrangler command that you lack permissions for)- Observe that this results in an auth error since the user (read) scope is missing:
โ
๏ธ wrangler 3.22.1
-------------------
โ [ERROR] A request to the Cloudflare API (/memberships) failed.
Authentication error [code: 10000]
Getting User settings...
๐ You are logged in with an OAuth Token. Unable to retrieve email for this user. Are you missing the `User->User Details->Read` permission?
๐ Token Permissions: If scopes are missing, you may need to logout and re-login.
Scope (Access)
- ai (read)
- offline_access
- Observe that this error is not logged to internal error reporting, even if telemetry is enabled
- Observe that there is no prompt to report this error to Cloudflare
I have seen this error state come up in the past in other instances where the --scopes flag was not used. There may be other paths to reproduce this, but the above is the clearest one I know about.
What might we do about it?
- It seems like we can prompt
wrangler login - Seems like a fatal exception like this, that is unhandled, should be reported back to us when telemetry is enabled?
- Seems like regardless of what is in the
--scopesfield, wrangler must always request theuser (read)scope? - https://github.com/cloudflare/workers-sdk/pull/4647
Most broadly โ how do we help developers recover from this state easily? What should we be doing automatically or telling them to do here?
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
No response
Hit this again today:
โ npx wrangler@latest kv:namespace create FOO
Need to install the following packages:
[email protected]
Ok to proceed? (y) y
โ
๏ธ wrangler 3.28.2
-------------------
๐ Creating namespace with title "test-version-binding-FOO"
โ [ERROR] A request to the Cloudflare API (/accounts/ID/storage/kv/namespaces) failed.
Authentication error [code: 10000]
Getting User settings...
๐ You are logged in with an OAuth Token, associated with the email [email protected]!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Account Name โ Account ID โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ acct โ j39j3o3jlsfsj3 โ
If wrangler sees this error โย seems like it should log me out behind the scenes?
same same, logout but can't login anymore...
having same issue, i tried many times. Created token will full permission. Still failed to login.
The error message is too simple, doesn't tell anything.