Skip to main content
POST
/
v1
/
oauth
/
token
Get an access token
curl --request POST \
  --url https://sandbox.apocor.ai/v1/oauth/token \
  --header 'Content-Type: application/json' \
  --data '
{
  "client_id": "apocor_1a2b3c4d5e6f7g8h",
  "client_secret": "apocor_sk_live_9i8u7y6t5r4e3w2q1..."
}
'
import requests

url = "https://sandbox.apocor.ai/v1/oauth/token"

payload = {
"client_id": "apocor_1a2b3c4d5e6f7g8h",
"client_secret": "apocor_sk_live_9i8u7y6t5r4e3w2q1..."
}
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({
client_id: 'apocor_1a2b3c4d5e6f7g8h',
client_secret: 'apocor_sk_live_9i8u7y6t5r4e3w2q1...'
})
};

fetch('https://sandbox.apocor.ai/v1/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://sandbox.apocor.ai/v1/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([
'client_id' => 'apocor_1a2b3c4d5e6f7g8h',
'client_secret' => 'apocor_sk_live_9i8u7y6t5r4e3w2q1...'
]),
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://sandbox.apocor.ai/v1/oauth/token"

payload := strings.NewReader("{\n \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\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://sandbox.apocor.ai/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox.apocor.ai/v1/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 \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\n}"

response = http.request(request)
puts response.read_body
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600
}
{
"error": {
"code": "INVALID_CLIENT",
"message": "Invalid client credentials"
}
}

Body

application/json
client_id
string
required

The prefix of your Apocor API key.

client_secret
string
required

The secret shown once when the key was created.

Response

Access token issued.

access_token
string
token_type
string
Example:

"Bearer"

expires_in
integer
Example:

3600