curl --request POST \
--url https://api.hq.zone/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"code": "<string>",
"code_verifier": "<string>",
"device_code": "<string>",
"redirect_uri": "<string>",
"refresh_token": "<string>"
}
'import requests
url = "https://api.hq.zone/v1/oauth/token"
payload = {
"grant_type": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"code": "<string>",
"code_verifier": "<string>",
"device_code": "<string>",
"redirect_uri": "<string>",
"refresh_token": "<string>"
}
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: '<string>',
client_id: '<string>',
client_secret: '<string>',
code: '<string>',
code_verifier: '<string>',
device_code: '<string>',
redirect_uri: '<string>',
refresh_token: '<string>'
})
};
fetch('https://api.hq.zone/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://api.hq.zone/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([
'grant_type' => '<string>',
'client_id' => '<string>',
'client_secret' => '<string>',
'code' => '<string>',
'code_verifier' => '<string>',
'device_code' => '<string>',
'redirect_uri' => '<string>',
'refresh_token' => '<string>'
]),
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://api.hq.zone/v1/oauth/token"
payload := strings.NewReader("{\n \"grant_type\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"code\": \"<string>\",\n \"code_verifier\": \"<string>\",\n \"device_code\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"refresh_token\": \"<string>\"\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://api.hq.zone/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"code\": \"<string>\",\n \"code_verifier\": \"<string>\",\n \"device_code\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"refresh_token\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hq.zone/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 \"grant_type\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"code\": \"<string>\",\n \"code_verifier\": \"<string>\",\n \"device_code\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"refresh_token\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"expires_in": 123,
"refresh_token": "<string>",
"scope": "<string>",
"token_type": "<string>"
}OAuth token endpoint
Exchanges an authorization code or a refresh token for tokens, accepting either application/x-www-form-urlencoded or application/json. For grant_type=authorization_code it verifies PKCE (S256 code_verifier against the stored challenge) and that client_id and redirect_uri match the original authorization; for grant_type=refresh_token it rotates the presented refresh token, carrying the original scopes forward, and detects reuse of an already-rotated token by revoking the entire token family. Confidential clients must authenticate with client_secret; public clients rely on PKCE. Returns an opaque short-lived Bearer access_token (expires_in seconds), a new rotating refresh_token, the token_type, and the space-delimited granted scope.
curl --request POST \
--url https://api.hq.zone/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"grant_type": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"code": "<string>",
"code_verifier": "<string>",
"device_code": "<string>",
"redirect_uri": "<string>",
"refresh_token": "<string>"
}
'import requests
url = "https://api.hq.zone/v1/oauth/token"
payload = {
"grant_type": "<string>",
"client_id": "<string>",
"client_secret": "<string>",
"code": "<string>",
"code_verifier": "<string>",
"device_code": "<string>",
"redirect_uri": "<string>",
"refresh_token": "<string>"
}
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: '<string>',
client_id: '<string>',
client_secret: '<string>',
code: '<string>',
code_verifier: '<string>',
device_code: '<string>',
redirect_uri: '<string>',
refresh_token: '<string>'
})
};
fetch('https://api.hq.zone/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://api.hq.zone/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([
'grant_type' => '<string>',
'client_id' => '<string>',
'client_secret' => '<string>',
'code' => '<string>',
'code_verifier' => '<string>',
'device_code' => '<string>',
'redirect_uri' => '<string>',
'refresh_token' => '<string>'
]),
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://api.hq.zone/v1/oauth/token"
payload := strings.NewReader("{\n \"grant_type\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"code\": \"<string>\",\n \"code_verifier\": \"<string>\",\n \"device_code\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"refresh_token\": \"<string>\"\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://api.hq.zone/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"code\": \"<string>\",\n \"code_verifier\": \"<string>\",\n \"device_code\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"refresh_token\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hq.zone/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 \"grant_type\": \"<string>\",\n \"client_id\": \"<string>\",\n \"client_secret\": \"<string>\",\n \"code\": \"<string>\",\n \"code_verifier\": \"<string>\",\n \"device_code\": \"<string>\",\n \"redirect_uri\": \"<string>\",\n \"refresh_token\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"expires_in": 123,
"refresh_token": "<string>",
"scope": "<string>",
"token_type": "<string>"
}Form-encoded token exchange (OAuth 2.1)
Exchanges an authorizationcode for tokens, or rotates a refresh token. The request body is application/x-www-form-urlencoded (per RFC 6749), not JSON.
grant_type=authorization_code— sendcode,redirect_uri,client_id, and the PKCEcode_verifiermatching thecode_challengefrom the authorize step.grant_type=refresh_token— sendrefresh_token. Refresh tokens rotate: each use returns a new one and invalidates the old (reuse is detected and revokes the chain).
Authorization: Bearer ...), a rotating refresh token, token_type, and expires_in. Access tokens last ~1 hour; refresh tokens ~30 days.Body
authorization_code or refresh_token grant. Accepts application/x-www-form-urlencoded (the OAuth default) OR application/json.
Confidential-client secret (client_secret_post). Public clients omit it and rely on PKCE.
Device Authorization Grant (RFC 8628): the opaque device_code the client
polls with. Carries its own PKCE code_verifier, same as the auth-code
grant.