Skip to main content
POST
/
realms
/
api
/
protocol
/
openid-connect
/
token
cURL
curl --request POST \
  --url https://account.belio.co.ke/realms/api/protocol/openid-connect/token \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'client_id=<string>' \
  --data 'client_secret=<string>' \
  --data grant_type=client_credentials
import requests

url = "https://account.belio.co.ke/realms/api/protocol/openid-connect/token"

payload = {
"client_id": "<string>",
"client_secret": "<string>",
"grant_type": "client_credentials"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}

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

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
client_id: '<string>',
client_secret: '<string>',
grant_type: 'client_credentials'
})
};

fetch('https://account.belio.co.ke/realms/api/protocol/openid-connect/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://account.belio.co.ke/realms/api/protocol/openid-connect/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "client_id=%3Cstring%3E&client_secret=%3Cstring%3E&grant_type=client_credentials",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://account.belio.co.ke/realms/api/protocol/openid-connect/token"

payload := strings.NewReader("client_id=%3Cstring%3E&client_secret=%3Cstring%3E&grant_type=client_credentials")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://account.belio.co.ke/realms/api/protocol/openid-connect/token")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("client_id=%3Cstring%3E&client_secret=%3Cstring%3E&grant_type=client_credentials")
.asString();
require 'uri'
require 'net/http'

url = URI("https://account.belio.co.ke/realms/api/protocol/openid-connect/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "client_id=%3Cstring%3E&client_secret=%3Cstring%3E&grant_type=client_credentials"

response = http.request(request)
puts response.read_body
{
  "access_token": "<string>",
  "expires_in": 123,
  "refresh_expires_in": 0,
  "token_type": "Bearer",
  "not-before-policy": 0,
  "scope": "<string>"
}
{
"error": "<string>",
"error_description": "<string>"
}
{
"error": "<string>",
"error_description": "<string>"
}
{
"error": "<string>",
"error_description": "<string>"
}
{
"error": "<string>",
"error_description": "<string>"
}
{
"error": "<string>",
"error_description": "<string>"
}

Body

application/x-www-form-urlencoded

Client authentication details

client_id
string
required

The client identifier

client_secret
string
required

The client secret

grant_type
enum<string>
default:client_credentials
required
Available options:
client_credentials

Response

Successful token response

access_token
string

The access token. This is used as a bearer token in the Authorization header of requests to the API.

expires_in
integer<int32>

Lifetime of the access token in seconds

refresh_expires_in
integer<int32>
default:0

Lifetime of the refresh token in seconds

token_type
enum<string>

Type of the token

Available options:
Bearer
not-before-policy
integer<int32>
default:0

Not Before Policy time

scope
string

Space separated list of scopes associated with the access token