Skip to content

Authentication

Client Credentials Flow

POST https://login.blooma.ai/oauth/token

This is the OAuth 2.0 grant that server processes use to access the Blooma API. Use this endpoint to directly request an Access Token by using your Client's credentials (a Client ID and a Client Secret) provided by Blooma for your API integration.

All data requests made to Blooma API endpoints must include a valid Access Token returned from this endpoint in the request header.

How to obtain client credentials

Reach out to your Blooma CX Manager to get Client credentials that can be used to authenticate your API integration with Blooma's APIs.

Parameters

grant_type string

Denotes the flow you are using. Should always be client_credentials.

audience string

The unique identifier of the target API you want to access. This will be in the format of {BASE_URL}/api/ for your dedicated Blooma instance.

client_id string

Your application's Client ID.

client_secret string

Your application's Client Secret.

Example

POST https://login.blooma.ai/oauth/token
Content-Type: application/x-www-form-urlencoded

audience={BASE_URL}/api/&grant_type=client_credentials&client_id={YOUR_CLIENT_ID}&client_secret={YOUR_CLIENT_SECRET}
curl --request POST \
    --url 'https://login.blooma.ai/oauth/token' \
    --header 'content-type: application/json' \
    --data "{
        \"client_id\": \"${YOUR_CLIENT_ID}\",
        \"client_secret\": \"${YOUR_CLIENT_SECRET}\",
        \"audience\": \"${BASE_URL}/api/\",
        \"grant_type\": \"client_credentials\"
    }"
HttpResponse<String> response = Unirest.post("https://login.blooma.ai/oauth/token")
    .header("content-type", "application/json")
    .body("{\"client_id\":\"YOUR_CLIENT_ID\",\"client_secret\":\"YOUR_CLIENT_SECRET\",\"audience\":\"${BASE_URL}/api/\",\"grant_type\":\"client_credentials\"}")
    .asString();
var client = new RestClient("https://login.blooma.ai/oauth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"client_id\":\"YOUR_CLIENT_ID\",\"client_secret\":\"YOUR_CLIENT_SECRET\",\"audience\":\"BASE_URL/api/\",\"grant_type\":\"client_credentials\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var request = require("request");

var options = {
    method: 'POST',
    url: 'https://login.blooma.ai/oauth/token',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    form: {
        client_id: YOUR_CLIENT_ID,
        client_secret: YOUR_CLIENT_SECRET,
        audience: `${BASE_URL}/api/`,
        grant_type: 'client_credentials'
    }
    };

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});
import json
import http.client

conn = http.client.HTTPSConnection("login.blooma.ai")

payload = {
    "client_id": YOUR_CLIENT_ID,
    "client_secret": YOUR_CLIENT_SECRET,
    "audience": f"{BASE_URL}/api/",
    "grant_type": "client_credentials"
}

headers = { "content-type": "application/json" }

conn.request("POST", "/oauth/token", json.dumps(payload), headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

200 OK

Type

application/json

Body

{
    "access_token": "eyJz93a...k4laUWw",
    "token_type": "Bearer",
    "scope": "USER",
    "expires_in": 86400
}

You can then use the returned token_type and access_token to access the Blooma API by including the following header in subsequent requests.

Header Sample
Authorization: Bearer eyJz93a...k4laUWw

Last update: 2024-09-24