Exchange an install code
curl --request POST \
--url https://api.reintersect.com/v0/apps/oauth/token \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.reintersect.com/v0/apps/oauth/token"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.reintersect.com/v0/apps/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.reintersect.com/v0/apps/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_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.reintersect.com/v0/apps/oauth/token"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.reintersect.com/v0/apps/oauth/token")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.reintersect.com/v0/apps/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyInstall
Exchange an install code
Trade the code from the install redirect for the install id.
POST
/
v0
/
apps
/
oauth
/
token
Exchange an install code
curl --request POST \
--url https://api.reintersect.com/v0/apps/oauth/token \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.reintersect.com/v0/apps/oauth/token"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.reintersect.com/v0/apps/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.reintersect.com/v0/apps/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_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.reintersect.com/v0/apps/oauth/token"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.reintersect.com/v0/apps/oauth/token")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.reintersect.com/v0/apps/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body
After an admin approves your app on the install link, exchange the
code from your server for the install id and granted scopes. There’s no long-lived token: mint
one-hour install tokens with Create an install token when you
need them.
Send your client ID and secret in the body, which is form-encoded as in OAuth 2.0. Responses carry
cache-control: no-store. Each client can make at most 60 exchanges a minute.
Body
Sendapplication/x-www-form-urlencoded.
| Field | Required | Description |
|---|---|---|
grant_type | Yes | authorization_code. |
code | Yes | The code from the redirect. |
redirect_uri | Yes | The same redirect_uri you sent on the install link. |
code_verifier | Yes | The PKCE verifier, 43 to 128 characters. |
client_id | Yes | Your app’s client ID. |
client_secret | Yes | Your app’s client secret. Never send it from a browser. |
Response
| Field | Description |
|---|---|
install_id | The install. Deliveries carry it in the reintersect-install header. |
workspace_id | The workspace the app was installed in. |
scope | The granted scopes, separated by spaces. |
Errors
_tag | Status | Fields | Cause |
|---|---|---|---|
ReintersectAppOAuthInvalidClientError | 401 | error: "invalid_client", error_description | Wrong client ID or secret. |
ReintersectAppOAuthInvalidGrantError | 400 | error: "invalid_grant", error_description | Unknown, expired or used code, different redirect_uri, or a verifier that doesn’t match. |
ReintersectApiRateLimitExceededError | 429 | Too many exchanges. |
Example
curl -X POST https://api.reintersect.com/v0/apps/oauth/token \
-H "content-type: application/x-www-form-urlencoded" \
--data-urlencode "grant_type=authorization_code" \
--data-urlencode "code=$CODE" \
--data-urlencode "redirect_uri=https://tasks.example.com/reintersect/callback" \
--data-urlencode "code_verifier=$CODE_VERIFIER" \
--data-urlencode "client_id=$REINTERSECT_APP_CLIENT_ID" \
--data-urlencode "client_secret=$REINTERSECT_APP_CLIENT_SECRET"
{ "install_id": "inst_01J9Z5M2", "workspace_id": "org_01H8XK", "scope": "blocks:write replies:write" }