curl --request POST \
--url https://api.example.com/v1/auth/token-exchange \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type= \
--data subject_token= \
--data subject_token_type= \
--data actor_token= \
--data actor_token_type= \
--data scope=import requests
url = "https://api.example.com/v1/auth/token-exchange"
payload = {
"grant_type": "",
"subject_token": "",
"subject_token_type": "",
"actor_token": "",
"actor_token_type": "",
"scope": ""
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: '',
subject_token: '',
subject_token_type: '',
actor_token: '',
actor_token_type: '',
scope: ''
})
};
fetch('https://api.example.com/v1/auth/token-exchange', 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.example.com/v1/auth/token-exchange",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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.example.com/v1/auth/token-exchange"
payload := strings.NewReader("grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope=")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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.example.com/v1/auth/token-exchange")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope=")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/auth/token-exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope="
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"issued_token_type": "<string>",
"expires_in": 123,
"scope": "<string>",
"token_type": "Bearer"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}Exchange an identity assertion for a member token
Obtain a short-lived token that acts as one member of the organization, for an approved app.
Form-encoded per RFC 8693 §2.1. The app sends its own machine access token as the actor and a signed identity assertion naming the member as the subject. The organization’s admin must have approved the app’s client in Settings, and the member must not have opted out of the app. The token lives 15 minutes, is read-only, carries at most the approval’s scopes, and is re-checked against the approval and the member’s choice on use.
Errors use the OAuth token-endpoint shape (error, error_description): 400
invalid_request / unsupported_grant_type / invalid_grant, 403 access_denied
with the reason, 503 temporarily_unavailable.
curl --request POST \
--url https://api.example.com/v1/auth/token-exchange \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type= \
--data subject_token= \
--data subject_token_type= \
--data actor_token= \
--data actor_token_type= \
--data scope=import requests
url = "https://api.example.com/v1/auth/token-exchange"
payload = {
"grant_type": "",
"subject_token": "",
"subject_token_type": "",
"actor_token": "",
"actor_token_type": "",
"scope": ""
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: '',
subject_token: '',
subject_token_type: '',
actor_token: '',
actor_token_type: '',
scope: ''
})
};
fetch('https://api.example.com/v1/auth/token-exchange', 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.example.com/v1/auth/token-exchange",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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.example.com/v1/auth/token-exchange"
payload := strings.NewReader("grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope=")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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.example.com/v1/auth/token-exchange")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope=")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/auth/token-exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=&subject_token=&subject_token_type=&actor_token=&actor_token_type=&scope="
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"issued_token_type": "<string>",
"expires_in": 123,
"scope": "<string>",
"token_type": "Bearer"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}Body
Response
A read-only token acting as the member was issued.
OAuth2 token-exchange response (RFC 8693 §2.2.1): a short-lived token that acts as one member.