Repository navigation
Description
Context
We use cf for day-to-day Workers development, and our developers increasingly run it through AI coding agents.
cf auth login grants a very broad set of permissions by default (475 scopes in our case, including membership, SSO and DNS writes), and the grant stays on disk until logout.
For agent-driven work we want the opposite: credentials limited to the account and permissions the task needs, and expiring within hours.
The natural way to do this would be to log in, mint a short-lived, scoped account API token as yourself, and log out right away.
That keeps no broad credential on disk, needs no extra service, and the audit log shows the person who created the token.
As far as we can tell, this is not possible today.
What we tried
Versions: cf 1.0.0-beta.13 and 1.0.0-beta.31, macOS, OAuth device flow.
The user is a Super Administrator of the account.
cf auth login --force --scopes account:read user:read account_api_tokens:create- Login succeeds, but the granted scopes are
user:read, offline_access, account:read. account_api_tokens:createis dropped without any message, even though it appears in the scope list built intocf(checked in 1.0.0-beta.13).
- Login succeeds, but the granted scopes are
cf accounts tokens create --name … --expires-on <now+1h> --policies '[{"effect":"allow","resources":{"com.cloudflare.api.account.<id>":"*"},"permission_groups":[{"id":"<Workers Scripts Write>"}]}]'403 [9109] Unauthorized to access requested resourceonPOST /accounts/<id>/tokens.cf accounts tokens permission-groups listalso fails.
- The same with the default login (
cf auth login --force): token creation still returns 403.- 1.0.0-beta.13 reported "475 selected"; 1.0.0-beta.31 reported "476 granted". In beta.31 the only token-related scopes in the grant were
access-service-token.readandaccess-service-token.write.
- 1.0.0-beta.13 reported "475 selected"; 1.0.0-beta.31 reported "476 granted". In beta.31 the only token-related scopes in the grant were
So neither a narrowed nor the default login can create an account API token, and there is no other way to get a short-lived, scoped credential from an interactive login.
Expected
Some supported way for a logged-in user to obtain a credential that is:
- limited to chosen permission groups and accounts,
- short-lived (hours), and
- attributed to that user in the audit log.
Possible directions
Any of these would solve it for us:
- Make
account_api_tokens:creategrantable when explicitly requested with--scopes, without adding it to the default grant (similar to the on-demand sensitive scope discussed in Support on-demand OAuth authorization for PlanetScale signature creation #248). - A command such as
cf auth token create --permissions <groups> --account <id> --ttl 12hthat mints a scoped, expiring token for the current user and prints or stores it. - Time-limited or preset logins, e.g.
cf auth login --preset workers-dev --ttl 12h, so the OAuth grant itself is narrow and expires.
Also related: when a requested scope is not granted, cf auth login should say which ones were dropped (see #552), and the granted list should be easy to inspect (#34).
Happy to provide more details or test a build.
Activity
workers-devprod commentedon Nov 16, 2026
Thanks for the detailed report.
cf auth loginonly gets the scopes the OAuth grant allows, soaccount_api_tokens:createisn't granted and token creation returns 403. Minting scoped, expiring credentials would be a change to the product, which we track in Discussions, so please follow and upvote it at #632.