Skip to content

Accept HTTP Basic client authentication at the Google token endpoint - #403

Closed
jychp wants to merge 3 commits into
vercel-labs:mainfrom
Unchallenged-com:google-token-basic-auth
Closed

jychp wants to merge 3 commits into
vercel-labs:mainfrom
Unchallenged-com:google-token-basic-auth

Conversation

@jychp

@jychp jychp commented Nov 13, 2026

Copy link
Copy Markdown
  • Read the client's credentials from an HTTP Basic Authorization header at POST /oauth2/token, as the client_secret_basic method the discovery document advertises, for authorization code and refresh token grants.
  • Return Google's 400 invalid_request when OAuth clients are configured and the body's credentials do not match the header, while accepting an identical duplicate, a matching client_id alone, or an empty body secret, as the real endpoint does.
  • Keep body credentials and the invalid_client errors unchanged, without a WWW-Authenticate header since Google sends none, with regression coverage and docs.

References:

Fixes #402

- Read the client's credentials from an HTTP Basic Authorization header when the body has none, as the client_secret_basic method the discovery document advertises.
- Keep body credentials and the invalid_client errors unchanged, with tests and docs.
- Return 400 invalid_request when a request carries an HTTP Basic Authorization header and a client secret, or a different client_id, in its body, as RFC 6749 section 5.2 defines for more than one client authentication method.
- Keep a matching client_id in the body accepted and apply the check only when OAuth clients are configured, with tests and docs.
- Return 400 invalid_request with Google's message only when body credentials do not match the HTTP Basic header, and accept an identical duplicate or an empty body secret, as the real token endpoint does.
- Keep the 401 invalid_client answers without a WWW-Authenticate challenge, as Google sends none, with tests and docs.
@vercel

vercel Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@jychp is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

// credentials in an HTTP Basic Authorization header, each form-urlencoded (RFC 6749, section 2.3.1).
let basic: { id: string; secret: string } | undefined;
const authHeader = c.req.header("Authorization") ?? "";
if (authHeader.startsWith("Basic ")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With OAuth clients configured, valid Authorization: basic … or Authorization: BASIC … credentials are ignored, causing header-only token requests to fail with 401 invalid_client.

Fix on Vercel

@jychp

jychp commented Nov 16, 2026

Copy link
Copy Markdown
Author

Superseded by #406.

@jychp jychp closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google: token endpoint ignores HTTP Basic client authentication

1 participant