Skip to main content
This guide walks you through obtaining access tokens for server-to-server authentication using the OAuth 2.0 client credentials flow. This is useful when your backend application needs to call other services or APIs on behalf of itself, without involving a user.

Prerequisites

Before you start, make sure you have:
  • A Prelude account with access to Prelude Auth
  • An Application ID (appID) — see Applications
  • Your Management API key for backend calls

How it works

The client credentials flow allows your backend application to:
  1. Register an OAuth client (a “service account”) with Prelude Auth
  2. Exchange the client credentials (ID and secret) for an access token
  3. Use the token to authenticate requests to your backend or other services
This flow is ideal for:
  • Service-to-service communication
  • Scheduled jobs and background tasks
  • Microservices that need to call each other
  • API integrations that don’t involve a user

Set up server tokens

1

Register an OAuth client

Create a new OAuth client registered for the client_credentials grant type:
The response includes your client_id and client_secret. Store the secret securely — you’ll need it to request tokens. The secret is only returned once — if you lose it, you’ll need to rotate the client.
2

Request an access token

Exchange your client credentials for an access token:
Alternatively, use HTTP Basic authentication:
The response contains:
Note: Client credentials tokens do not include a refresh_token. When the token expires, request a new one.
3

Use the access token

Include the token in the Authorization header of your requests:
On your backend, verify the token signature using the JWKS endpoint. The token’s subject (sub claim) will be the client ID.

Token claims

Tokens issued via client credentials include the following claims:
Key differences from user tokens:
  • sub is the client ID (not a user ID)
  • session_id is absent — there is no session
  • Tokens are not revocable via session invalidation
  • Tokens expire after 1 hour (configurable)

Client rotation

If you suspect your client secret has been compromised:
  1. Create a new client with the same scopes and grant types
  2. Update your application to use the new credentials
  3. Delete the compromised client using the Management API

What’s next?