Skip to content
  • There are no suggestions because the search field is empty.

Obtain a Bearer token

Generate an access token for use with the Casebook API

Introduction

The Casebook API is secured with OAuth 2.0 authentication.  Every request to the Casebook API requires an Authorization header containing a valid OAuth 2.0 Bearer token.

This guide provides instructions and code samples for obtaining a Bearer token for use with the Casebook API.

Prerequisites

Your organization must be licensed for External Data Interoperability (API) to interact with the Casebook API.

You will need to register an incoming application before starting this guide.

Instructions

Get started by noting three details from your incoming integration:

  1. Navigate to Casebook → Admin → Global → Integrations → Incoming integrations
  2. Locate the incoming integration which you would like to use
  3. Click the expand button on the external application to display the Client ID and Callback URL
  4. Click the “View client secret” (key) icon to display the Client Secret

If you do not yet have an application, start with Register an incoming application instructions.

Obtain a Bearer token

Next, use the "Obtain a Bearer token" request to exchange these details for a Bearer token.

POST <YOUR_CALLBACK_URL>/oauth2/token 
  • Headers:
    • Content-Type: application/x-www-form-urlencoded
  • Body: N/A
  • Query Parameters:

    • client_id (Required): <YOUR_CLIENT_ID>
    • client_secret (Required): <YOUR_CLIENT_SECRET>
    • grant_type (Required): client_credentials

Tips

Bearer tokens are valid for one hour, so be sure to refresh your token regularly or before each new interaction with the Casebook API

Examples

cURL

curl -X POST "<YOUR_CALLBACK_URL>/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=<YOUR_CLIENT_ID>" \
-d "client_secret=<YOUR_CLIENT_SECRET>" \
-d "grant_type=client_credentials"

JavaScript

const clientId = '<YOUR_CLIENT_ID>';
const clientSecret = '<YOUR_CLIENT_SECRET>';
const callbackUrl = '<YOUR_CALLBACK URL>';

async function getAccessToken() {
  const params = new URLSearchParams();
  params.append('client_id', clientId);
  params.append('client_secret', clientSecret);
  params.append('grant_type', 'client_credentials');

  const authenticationResponse = await axios({
   url: callbackUrl + '/oauth2/token',
   headers: { 'Content-Type', 'application/x-www-form-urlencoded' },
   method: 'post',
   data: params,
  });

 const token = authenticationResponse.data.access_token; // ← Look here!

  return token;
}

Python

import requests

url = "<YOUR_CALLBACK_URL>/oauth2/token"

payload = {
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "grant_type": "client_credentials",
  "redirect_uri": "YOUR_CALLBACK_URL"
}

headers = {
  "Content-Type": "application/x-www-form-urlencoded"
}

response = requests.post(url, data=payload, headers=headers)

if response.status_code == 200:
 token = response.json()["access_token"] # ← Look here!
  print("Access token:", token)
else:
  print("Error:", response.status_code, response.text)

Next steps

Next, use your Bearer token to make a request to the Casebook API:


For more help with the Casebook API, get in touch with the Casebook Support team.