cloudflare / cloudflare/cloudflare-os

Preserve Cloudflare OAuth token exchange errors

Open
#323 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
9.9k
Forks
1.2k
Avg merge
1d 20h
Merged PRs (30d)
107

Description

The Cloudflare Gatekeeper collapses every non-2xx token response into `null`, so `acceptAuthCode()` reports the same "exchange failed or returned no refresh token" error for invalid client credentials, rejected grants, and provider failures.

This makes production OAuth failures unnecessarily difficult to diagnose. In one deployment, the provider returned `401 invalid_client`, but the actionable cause was discarded before it reached Worker logs.

Expected behavior:

- Preserve the HTTP status and OAuth `error` / `error_description` fields for rejected token exchanges.
- Do not include client credentials, authorization codes, access tokens, or refresh tokens in the error.
- Keep successful token parsing unchanged.

The provider error payload is the standard OAuth response and gives operators enough information to distinguish client configuration from grant and scope failures.

Contributor guide

Open the contributing guide

Research direction

Start at the Cloudflare Gatekeeper token exchange and the acceptAuthCode() entry point described in the issue. Trace how non-2xx responses become null, then verify that rejected exchanges retain their HTTP status and OAuth error fields without exposing credentials or tokens, while successful token parsing remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.