Generate Access Token
1 min
token
Generate access token
POST
https://api-sandbox.klavi.ai/token
Header Parameters
- Content-TypestringrequiredDescription
Body Parameters
- grant_typestringrequiredDescription
- scopestringrequiredDescription
- client_idstringrequiredDescription
- client_secretstringrequiredDescription
Response
- access_tokenstringDescription
- expires_innumberDescription
- token_typestringDescription
- scopestringDescription
curl
curl --location 'https://api-sandbox.klavi.ai/token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data '{
"grant_type": "String",
"scope": "String",
"client_id": "String",
"client_secret": "String"
}'nodejs
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api-sandbox.klavi.ai/token',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: JSON.stringify({
"grant_type": "String",
"scope": "String",
"client_id": "String",
"client_secret": "String"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
javascript
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var raw = JSON.stringify({
"grant_type": "String",
"scope": "String",
"client_id": "String",
"client_secret": "String"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api-sandbox.klavi.ai/token", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));python
import requests
import json
url = "https://api-sandbox.klavi.ai/token"
payload = json.dumps({
"grant_type": "String",
"scope": "String",
"client_id": "String",
"client_secret": "String"
})
headers = {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api-sandbox.klavi.ai/token")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/x-www-form-urlencoded"
request.body = JSON.dump({
"grant_type": "String",
"scope": "String",
"client_id": "String",
"client_secret": "String"
})
response = https.request(request)
puts response.read_body
200
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJYQnhoZ1NwT0RQZGlJNUFaazNKclppNFNBZGN2SGoybGN2a05mQjFTdzNRIn0.eyJleHAiOjE3NTE1OTk4NzksImlhdCI6MTc1MTU5OTU3OSwianRpIjoiMjQ4MWFiODYtMGNmNC00MzgzLWIyOWQtNWRhMGY3NTYzZTY1IiwiaXNzIjoiaHR0cHM6Ly9tdGxzLWFwaS1zb3Blbi5rbGF2aS5haS9yZWFsbXMvS2xhdmlPQXV0aCIsInN1YiI6IjNlYWMyNmJhLTliN2QtNGYzMi05OTNlLTNjY2JiM2NhZjYxNCIsInR5cCI6IkJlYXJlciIsImF6cCI6IktsYXZpVGVzdCIsImFjciI6InVybjpicmFzaWw6b3BlbmJhbmtpbmc6bG9hMiIsInNjb3BlIjoia2xhYXMiLCJjbGllbnRIb3N0IjoiMTAuMi4xMjguMjE3IiwiY2xpZW50QWRkcmVzcyI6IjEwLjIuMTI4LjIxNyIsImNsaWVudF9pZCI6IktsYXZpVGVzdCJ9.GYABzepeD2exChi_Jsdv8uvwOMfPWNn1TP80ct5dNP6DMh5sjfw3X394g0pLD8iry75QFBVVZ527bUmUl9DHqs6Z32N3a-ex6SMYt9eoM-vTT8CYNRlwpG_RjwXQps05HFchkkH-C48h8POu8EvL5d2f0eFNpgn6lVYz9MDeKPaUKInM6aNxN4UcLff7WrQVSoSzAooVQ5eB_j7lxMnDaZn7KTzvweuWK8b5MR5pZF_OZETS5VH_9XLAZW-Gk5vmlxr_7quJR2IIIHQbkOGU8BFc0Aa8Qm1v75Fa_fdBpOrK6sF3ibgK_ubn4BfPvGwtfoFYgVWbaIoB9WnUgSQDDQ",
"expires_in": 300,
"token_type": "Bearer",
"scope": "klaas"
}