Skip to main content

Setup

1

Get credentials

Create an OAuth client in the Cloudflare dashboard, add user-details.read as a required scope, and register the redirect URI:
2

Configure

lib/theauth.ts

Scopes

Default scopes: user-details.read. It must also be a required scope on the OAuth client, or sign in cannot complete. Any other Cloudflare API scope can be added through scopes, and must be selected on the OAuth client too.

How it works

  • Authorization Code flow with PKCE (S256). The endpoints are https://dash.cloudflare.com/oauth2/auth and https://dash.cloudflare.com/oauth2/token.
  • Client credentials go in an Authorization: Basic header by default. If the client is registered for client_secret_post, pass tokenEndpointAuthMethod: 'client_secret_post'.
  • Cloudflare’s OIDC userinfo endpoint returns only sub, so the profile is read from GET https://api.cloudflare.com/client/v4/user. The answer is wrapped in { success, errors, result }. The name is first_name and last_name joined, with the email as the fallback. There is no avatar.
  • /user does not say whether the email is verified, so the OAuth plugin will not link a Cloudflare login to an existing account by email.
  • Clients without a secret (token auth method none) are not supported by this provider.
Vendor docs: Integrate your OAuth client with Cloudflare.

Endpoints

Last modified on October 19, 2026