Exchange authorization code or refresh token for tokens
curl --request POST \
--url https://api.cal.com/v2/auth/oauth2/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "my-client-id",
"grant_type": "authorization_code",
"code": "abc123",
"redirect_uri": "https://example.com/callback",
"client_secret": "<string>"
}
'import requests
url = "https://api.cal.com/v2/auth/oauth2/token"
payload = {
"client_id": "my-client-id",
"grant_type": "authorization_code",
"code": "abc123",
"redirect_uri": "https://example.com/callback",
"client_secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_id: 'my-client-id',
grant_type: 'authorization_code',
code: 'abc123',
redirect_uri: 'https://example.com/callback',
client_secret: '<string>'
})
};
fetch('https://api.cal.com/v2/auth/oauth2/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.cal.com/v2/auth/oauth2/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' => 'my-client-id',
'grant_type' => 'authorization_code',
'code' => 'abc123',
'redirect_uri' => 'https://example.com/callback',
'client_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.cal.com/v2/auth/oauth2/token"
payload := strings.NewReader("{\n \"client_id\": \"my-client-id\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"abc123\",\n \"redirect_uri\": \"https://example.com/callback\",\n \"client_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.cal.com/v2/auth/oauth2/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"my-client-id\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"abc123\",\n \"redirect_uri\": \"https://example.com/callback\",\n \"client_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cal.com/v2/auth/oauth2/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"my-client-id\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"abc123\",\n \"redirect_uri\": \"https://example.com/callback\",\n \"client_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 1800,
"scope": "BOOKING_READ BOOKING_WRITE"
}OAuth2
Exchange authorization code or refresh token for tokens
RFC 6749-compliant token endpoint. Pass client_id in the request body (Section 2.3.1). Use grant_type ‘authorization_code’ to exchange an auth code for tokens, or ‘refresh_token’ to refresh an access token. Accepts both application/x-www-form-urlencoded (standard per RFC 6749 Section 4.1.3) and application/json content types.
POST
/
v2
/
auth
/
oauth2
/
token
Exchange authorization code or refresh token for tokens
curl --request POST \
--url https://api.cal.com/v2/auth/oauth2/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "my-client-id",
"grant_type": "authorization_code",
"code": "abc123",
"redirect_uri": "https://example.com/callback",
"client_secret": "<string>"
}
'import requests
url = "https://api.cal.com/v2/auth/oauth2/token"
payload = {
"client_id": "my-client-id",
"grant_type": "authorization_code",
"code": "abc123",
"redirect_uri": "https://example.com/callback",
"client_secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
client_id: 'my-client-id',
grant_type: 'authorization_code',
code: 'abc123',
redirect_uri: 'https://example.com/callback',
client_secret: '<string>'
})
};
fetch('https://api.cal.com/v2/auth/oauth2/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.cal.com/v2/auth/oauth2/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' => 'my-client-id',
'grant_type' => 'authorization_code',
'code' => 'abc123',
'redirect_uri' => 'https://example.com/callback',
'client_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.cal.com/v2/auth/oauth2/token"
payload := strings.NewReader("{\n \"client_id\": \"my-client-id\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"abc123\",\n \"redirect_uri\": \"https://example.com/callback\",\n \"client_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.cal.com/v2/auth/oauth2/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"my-client-id\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"abc123\",\n \"redirect_uri\": \"https://example.com/callback\",\n \"client_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cal.com/v2/auth/oauth2/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"client_id\": \"my-client-id\",\n \"grant_type\": \"authorization_code\",\n \"code\": \"abc123\",\n \"redirect_uri\": \"https://example.com/callback\",\n \"client_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 1800,
"scope": "BOOKING_READ BOOKING_WRITE"
}Authorizations
Body
application/json
Token request body. client_id is required. Accepts application/x-www-form-urlencoded (RFC 6749 standard) or application/json. Use grant_type 'authorization_code' with client_secret (confidential) or code_verifier (public/PKCE), or grant_type 'refresh_token' with client_secret (confidential) or just the refresh_token (public).
- Exchange - Confidential Client
- Exchange - Public Client
- Refresh - Confidential Client
- Refresh - Public Client
Response
200 - application/json
Was this page helpful?