Get a token
curl --request POST \
--url https://login-demo.taxrock.com/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"audience": "https://api.taxrock.com"
}
'import requests
url = "https://login-demo.taxrock.com/oauth/token"
payload = {
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"audience": "https://api.taxrock.com"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
grant_type: 'client_credentials',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
audience: 'https://api.taxrock.com'
})
};
fetch('https://login-demo.taxrock.com/oauth/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://login-demo.taxrock.com/oauth/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 => json_encode([
'grant_type' => 'client_credentials',
'client_id' => 'YOUR_CLIENT_ID',
'client_secret' => 'YOUR_CLIENT_SECRET',
'audience' => 'https://api.taxrock.com'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://login-demo.taxrock.com/oauth/token"
payload := strings.NewReader("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"YOUR_CLIENT_ID\",\n \"client_secret\": \"YOUR_CLIENT_SECRET\",\n \"audience\": \"https://api.taxrock.com\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://login-demo.taxrock.com/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"YOUR_CLIENT_ID\",\n \"client_secret\": \"YOUR_CLIENT_SECRET\",\n \"audience\": \"https://api.taxrock.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://login-demo.taxrock.com/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"YOUR_CLIENT_ID\",\n \"client_secret\": \"YOUR_CLIENT_SECRET\",\n \"audience\": \"https://api.taxrock.com\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5c...",
"expires_in": 86400,
"token_type": "Bearer"
}{
"error": "access_denied",
"error_description": "Unauthorized"
}{
"error": "access_denied",
"error_description": "Client is not authorized to access \"https://api.taxrock.com\"."
}OAuth
Get a token
POST /oauth/token
POST
/
oauth
/
token
Get a token
curl --request POST \
--url https://login-demo.taxrock.com/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"audience": "https://api.taxrock.com"
}
'import requests
url = "https://login-demo.taxrock.com/oauth/token"
payload = {
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"audience": "https://api.taxrock.com"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
grant_type: 'client_credentials',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
audience: 'https://api.taxrock.com'
})
};
fetch('https://login-demo.taxrock.com/oauth/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://login-demo.taxrock.com/oauth/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 => json_encode([
'grant_type' => 'client_credentials',
'client_id' => 'YOUR_CLIENT_ID',
'client_secret' => 'YOUR_CLIENT_SECRET',
'audience' => 'https://api.taxrock.com'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://login-demo.taxrock.com/oauth/token"
payload := strings.NewReader("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"YOUR_CLIENT_ID\",\n \"client_secret\": \"YOUR_CLIENT_SECRET\",\n \"audience\": \"https://api.taxrock.com\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://login-demo.taxrock.com/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"YOUR_CLIENT_ID\",\n \"client_secret\": \"YOUR_CLIENT_SECRET\",\n \"audience\": \"https://api.taxrock.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://login-demo.taxrock.com/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"YOUR_CLIENT_ID\",\n \"client_secret\": \"YOUR_CLIENT_SECRET\",\n \"audience\": \"https://api.taxrock.com\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5c...",
"expires_in": 86400,
"token_type": "Bearer"
}{
"error": "access_denied",
"error_description": "Unauthorized"
}{
"error": "access_denied",
"error_description": "Client is not authorized to access \"https://api.taxrock.com\"."
}Fill in your
client_id and client_secret, then Run it. The access_token you receive is the Bearer
credential for every other endpoint.
Cache the access token and reuse it until it expires. expires_in gives its lifetime in seconds. Request a new
token when the cached one expires or the API answers 401, not once per call.Body
application/json
Client credentials token request.
Must be client_credentials.
Available options:
client_credentials Your client ID for the environment.
Your client secret for the environment.
https://api.taxrock.com (the same in both environments).
Available options:
https://api.taxrock.com 
