Skip to main content

Client Credentials

The simplest way to authenticate — exchange a client_id and client_secret for an access token.

When to Use

  • Server-to-server communication
  • AI agent authentication
  • Background services

Flow

POST /oauth/token
Content-Type: application/json

{
  "grant_type": "client_credentials",
  "client_id": "your-client-id",
  "client_secret": "your-client-secret"
}
Response:
{
  "access_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 3600
}

SDK Usage

import { BKeyClient } from '@bkey/sdk';

const bkey = new BKeyClient({
  clientId: process.env.BKEY_CLIENT_ID!,
  clientSecret: process.env.BKEY_CLIENT_SECRET!,
});

// Token is automatically obtained and refreshed