Skip to content

Can't edit API tokens with an OAuth login: cf user tokens update / cf accounts tokens always 403, and no scope or message explains why #616

Open

Description

@heredia21

Summary of the issue

cf user tokens update/create/roll and cf accounts tokens list/create/update show up in cf --help and cf cli search, but they can't work with a cf auth login session. The OAuth grant has no API-token scope, so every call returns 403 [9109] Unauthorized to access requested resource.

Use case: an existing user API token (used by a production integration) needs one more permission group (Browser Run Write). Read access works with the OAuth login: cf user tokens get <id> returns the token and its policies, and cf user tokens permission-groups list returns the group IDs. --dry-run also builds the correct PUT /user/tokens/<id> body. The real update then fails with 403. Neither the CLI nor cf auth scopes says that token management needs a separate API token. cf auth scopes --all lists no user-token or account-token scope (only access-service-token), and Account & Billing shows 14/15 with no hint about which scope is missing.

Feature request, any of these would help:

  1. Make API-token management grantable through OAuth on request, e.g. cf auth login --scopes user_api_tokens:write or an on-demand prompt the first time a tokens command runs. Editing a token's permissions is a common day-two task.
  2. If that is deliberately not offered over OAuth, say so up front. cf user tokens * / cf accounts tokens * should fail before the request with a clear message, e.g. "API token management isn't available with an OAuth login; set CLOUDFLARE_API_TOKEN to a token with 'API Tokens Write'". cf auth scopes should also list the ungranted scope.
  3. Print a dashboard deep link for the edit as a fallback (https://dash.cloudflare.com/profile/api-tokens with the token preselected).

Related: #607 (minting short-lived account tokens from a login), #552 (reporting dropped scopes).

Expected behaviour

A user logged in with cf auth login can add a permission group to their own existing API token. Failing that, the CLI explains before sending the request that this operation needs an API token with API Tokens Write, rather than returning a generic 403.

Version of cf used

1.0.0-beta.28

System information and package versions

Linux x86_64, Node 22.23.4, OAuth login (default profile, default scopes).

Reproduction (optional)

cf auth login                                   # default scopes
cf user tokens get <token-id>                   # works
cf user tokens permission-groups list           # works
cf user tokens update <token-id> --body @body.json --dry-run   # shows a correct PUT
cf user tokens update <token-id> --body @body.json             # 403
CLOUDFLARE_ACCOUNT_ID=<account-id> cf accounts tokens list     # 403
cf auth scopes --all | grep -i token            # only access-service-token

body.json is the token's current name, status and policies with one extra {"id": "<Browser Run Write group id>"} in permission_groups.

Relevant error logs (optional)

┌ APIError
│ [9109] Unauthorized to access requested resource
│ 403 Forbidden · HTTP /user/tokens/<token-id>
└

→ Check your API token permissions

Activity

  1. edmundhung commented on Nov 17, 2026

    @edmundhung
    Member

    Thanks for the report! cf can manage user API tokens with an OAuth login starting in 1.0.0-beta.27 (cloudflare/workers-sdk#16557). Logins created before that need to log in again to get the new permission:

    cf auth login --force
    cf auth scopes --filter tokens

    Once user-api-tokens.write shows up, cf user tokens update should work. If it doesn't appear, let us know which cf version you're on and whether you logged in with --device.

  2. petebacondarwin commented on Nov 22, 2026

    @petebacondarwin
    Collaborator

    There are two separate OAuth permission paths here. For cf user tokens update, were you able to retry after cf auth login --force and confirm that cf auth scopes --filter tokens shows user-api-tokens.write? If the scope is missing or the command still returns 403, please share your cf version, whether you used --device, and the error code.

    For cf accounts tokens list, cloudflare/developer-platform#87 tracks a related account-token delegation question, but it doesn’t cover the list failure you reported. If listing still returns 403 after signing in again, please share the error code for that command too, so we can get it to the right team. No tokens or credentials needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions