curl --request POST \
--url https://api.example.com/v2/auth/tokens/import \
--header 'Content-Type: application/json' \
--data '
{
"provider_id": "<string>",
"access_token": "<string>",
"refresh_token": "<string>",
"expires_in_seconds": 123,
"scopes": [],
"metadata": {},
"is_default": true
}
'import requests
url = "https://api.example.com/v2/auth/tokens/import"
payload = {
"provider_id": "<string>",
"access_token": "<string>",
"refresh_token": "<string>",
"expires_in_seconds": 123,
"scopes": [],
"metadata": {},
"is_default": True
}
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({
provider_id: '<string>',
access_token: '<string>',
refresh_token: '<string>',
expires_in_seconds: 123,
scopes: [],
metadata: {},
is_default: true
})
};
fetch('https://api.example.com/v2/auth/tokens/import', 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/v2/auth/tokens/import",
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([
'provider_id' => '<string>',
'access_token' => '<string>',
'refresh_token' => '<string>',
'expires_in_seconds' => 123,
'scopes' => [
],
'metadata' => [
],
'is_default' => true
]),
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.example.com/v2/auth/tokens/import"
payload := strings.NewReader("{\n \"provider_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"refresh_token\": \"<string>\",\n \"expires_in_seconds\": 123,\n \"scopes\": [],\n \"metadata\": {},\n \"is_default\": true\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.example.com/v2/auth/tokens/import")
.header("Content-Type", "application/json")
.body("{\n \"provider_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"refresh_token\": \"<string>\",\n \"expires_in_seconds\": 123,\n \"scopes\": [],\n \"metadata\": {},\n \"is_default\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v2/auth/tokens/import")
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 \"provider_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"refresh_token\": \"<string>\",\n \"expires_in_seconds\": 123,\n \"scopes\": [],\n \"metadata\": {},\n \"is_default\": true\n}"
response = http.request(request)
puts response.read_body{
"token_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Import Oauth Token
Persist a directly-obtained OAuth token (no authorization-code exchange).
The Slack managed-install flow receives a bot token inline from
apps.managedInstall instead of through the browser OAuth redirect. This
stores it (Fernet-encrypted at rest, via create_oauth_token) for the
caller’s org/user against an existing provider. Requiring the provider to
already exist in the caller’s org scopes the write and blocks cross-org
token creation. The token value is never logged or returned.
curl --request POST \
--url https://api.example.com/v2/auth/tokens/import \
--header 'Content-Type: application/json' \
--data '
{
"provider_id": "<string>",
"access_token": "<string>",
"refresh_token": "<string>",
"expires_in_seconds": 123,
"scopes": [],
"metadata": {},
"is_default": true
}
'import requests
url = "https://api.example.com/v2/auth/tokens/import"
payload = {
"provider_id": "<string>",
"access_token": "<string>",
"refresh_token": "<string>",
"expires_in_seconds": 123,
"scopes": [],
"metadata": {},
"is_default": True
}
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({
provider_id: '<string>',
access_token: '<string>',
refresh_token: '<string>',
expires_in_seconds: 123,
scopes: [],
metadata: {},
is_default: true
})
};
fetch('https://api.example.com/v2/auth/tokens/import', 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/v2/auth/tokens/import",
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([
'provider_id' => '<string>',
'access_token' => '<string>',
'refresh_token' => '<string>',
'expires_in_seconds' => 123,
'scopes' => [
],
'metadata' => [
],
'is_default' => true
]),
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.example.com/v2/auth/tokens/import"
payload := strings.NewReader("{\n \"provider_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"refresh_token\": \"<string>\",\n \"expires_in_seconds\": 123,\n \"scopes\": [],\n \"metadata\": {},\n \"is_default\": true\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.example.com/v2/auth/tokens/import")
.header("Content-Type", "application/json")
.body("{\n \"provider_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"refresh_token\": \"<string>\",\n \"expires_in_seconds\": 123,\n \"scopes\": [],\n \"metadata\": {},\n \"is_default\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v2/auth/tokens/import")
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 \"provider_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"refresh_token\": \"<string>\",\n \"expires_in_seconds\": 123,\n \"scopes\": [],\n \"metadata\": {},\n \"is_default\": true\n}"
response = http.request(request)
puts response.read_body{
"token_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Body
Import a directly-obtained OAuth token (no authorization-code exchange).
Used by the Slack managed-install flow, which receives a bot token inline
from apps.managedInstall rather than via the browser OAuth redirect. The
token is persisted for the caller's org/user against provider_id (which
must already exist in the caller's org).
Response
Successful Response
Response for a token import — the created token id only, no secrets.
Was this page helpful?

