← Blog

The token we asked for — then rejected

November 21, 2026 · Inside OnePress

This week we found a feature that had never worked — not "worked poorly", not "worked sometimes": never. The Cloudflare Pages channel in Settings → Channels had been live for weeks, fully documented, sitting there with its two little input fields, and the connection table contained exactly one row: our own test account.

We found out because someone hit the wall: the request log showed a real account get rejected twice in a row, then stop trying. When we replayed the flow ourselves, the reason turned out to be embarrassingly structural.

What the channel is supposed to do

The idea is simple and, we still think, right: you paste a Cloudflare account id and an API token into Settings → Channels once. After that the agent can take a workspace folder — say, the little web app it just built for you — and deploy it to your own Cloudflare Pages project. You get a real your-project.pages.dev URL on infrastructure you own and control.

Because the token is powerful, our instructions everywhere — the settings hint, the docs, what the agent tells users — all say the same thing: create a custom token with exactly one permission, Account → Cloudflare Pages → Edit. Minimal scope is the entire point. You should not hand an agent a key that can also fiddle with your DNS.

The bug: a bouncer checking for the wrong badge

When a user clicks Connect, we validate the credential by actually calling Cloudflare — good instinct. The problem is which endpoint we picked: GET /accounts/{account_id}. Per Cloudflare's own docs, that endpoint requires broad account-level permission groups like Account Settings Read — permissions that a token scoped to "Pages Edit" deliberately does not have.

So the sequence was: user follows our instructions to the letter → creates the correctly minimal token → we call an endpoint that token cannot touch → Cloudflare answers 403 → we tell the user "Cloudflare rejected the credentials" → nothing is saved → the agent keeps reporting "not connected". A perfectly-scoped credential, shaped exactly the way we prescribed, could never pass our own front door.

The kicker: the deployment itself never needed that endpoint at all. We had built a bouncer that demanded a badge the job doesn't use — while turning away the badge the job actually requires.

The fix: verify the thing you actually need

The connection check is now two stages, each testing something real:

  • GET /user/tokens/verify — any valid token passes this, regardless of scope. It separates "the token is dead / mis-pasted" from "the token is fine but scoped wrong", so the error message can say which problem you actually have.
  • GET /accounts/{id}/pages/projects — this is the permission deployment genuinely needs. A Pages-scoped token answers it; a token without Pages access fails with an honest "your token is valid but lacks Pages on this account".

The account display name is now best-effort: a wide-permission token can read it, a minimal one can't, so we fall back to the account id prefix. Cosmetic, irrelevant to the deploy.

The honest edges

Three things we won't paper over. First, the failure wasn't exotic: one rejection died in 18 milliseconds on local validation — the account id never made it out of the form. A 32-hex id is a paste error waiting to happen, doubly so on a phone keyboard. The connect flow is fiddly even when it works; the bug just made sure it couldn't.

Second, a broader pattern the episode surfaced: when a paved path fails, people take shortcuts — and shortcuts route around our safeguards. For credential-based channels, the unsafe version of that shortcut is a secret ending up in a place it was never designed to live, like a chat message. Credentials entered through Channels are AES-256-GCM encrypted at rest and never echoed back to the agent or the API; a secret pasted into a conversation lives in plain history instead. Treating "a credential ended up in chat" as a first-class case — detected, and steered into the encrypted store — is now on our list, not filed under shrugs.

Third, the meta-lesson applies far beyond Cloudflare: validate against the requirement, not a convenient proxy. Any credential check that demands more privilege than the feature itself uses will quietly reject the most security-conscious users — the ones who actually scoped their token. Meanwhile the permissive ones sail through. That's a selection pressure pointed exactly backwards.

The fix is live. If you tried connecting Cloudflare Pages before and gave up — it was us, not you.

Reading this and have thoughts?

Spot a mistake, disagree, or want a follow-up? Tell us — a human reads it.

Inside OnePress — the build log

More posts like this, plus the weekly AI digest, straight to your inbox.

Get the build log in your inbox →