Skip to main content

Overview

Manage OAuth 2.0 clients for your SuperTokens instance. OAuth clients represent applications that can authenticate users through your OAuth provider.

GET /recipe/oauth/clients

Retrieve a specific OAuth client by ID.

Query Parameters

  • clientId (string, required): The OAuth client ID

Response

Example

POST /recipe/oauth/clients

Create a new OAuth client.

Request Body

Parameters

  • clientId (string, optional): Custom client ID. If not provided, a random ID with prefix stcl_ is generated
  • clientName (string, optional): Human-readable client name
  • scope (string, optional): Default OAuth scopes for this client
  • redirectUris (array, required): Allowed redirect URIs for authorization callbacks
  • grantTypes (array, required): Allowed grant types (e.g., ["authorization_code", "refresh_token"])
  • responseTypes (array, required): Allowed response types (e.g., ["code"])
  • tokenEndpointAuthMethod (string, optional): Method for authenticating at token endpoint
  • enableRefreshTokenRotation (boolean, optional): Enable refresh token rotation for enhanced security. Defaults to false

Response

Example

PUT /recipe/oauth/clients

Update an existing OAuth client.

Request Body

Parameters

  • clientId (string, required): The client ID to update
  • All other parameters are optional and will update the corresponding client configuration
  • Omitted parameters will retain their existing values

Response

Same structure as POST response with updated client information.

Example

GET /recipe/oauth/clients/list

List all OAuth clients for the current app.

Query Parameters

  • pageSize (number, optional): Number of clients per page (max 500)
  • pageToken (string, optional): Pagination token from previous response

Response

Example

Implementation Details

  • Located in: src/main/java/io/supertokens/webserver/api/oauth/CreateUpdateOrGetOAuthClientAPI.java:57 and OAuthClientListAPI.java:37
  • Recipe: OAUTH
  • Default client configuration:
    • accessTokenStrategy: “jwt”
    • skipConsent: true
    • subjectType: “public”
  • Client IDs are automatically prefixed with stcl_ if not provided
  • Client credentials are encrypted and stored securely
  • Clients are scoped to apps using an owner field: {connectionUriDomain}_{appId}
  • Client secrets are returned only on creation and retrieval, not in list operations
  • Refresh token rotation can be enabled per-client for enhanced security

Client Credentials Flow

If a client is configured with only the client_credentials grant type, it is marked as a client credentials only client (isClientCredentialsOnly: true). This is used for machine-to-machine authentication.

Refresh Token Rotation

When enableRefreshTokenRotation is true:
  • Each refresh token can only be used once
  • Using a refresh token issues a new refresh token and invalidates the old one
  • This prevents refresh token reuse attacks
  • When false, the same refresh token can be used multiple times until it expires