token-exchange
Exchange user company token for JWT
Exchange a user-company token for a bearer JWT (the inverse of
jwt_exchange). The token is supplied in the request body, so no bearer
header is required. Returns 401 when the user-company token is blank or does
not match a user company.
PUT
/
api
/
user_companies
/
token_exchange
Exchange user company token for JWT
curl --request PUT \
--url https://api.fluid.app/api/user_companies/token_exchange \
--header 'Content-Type: application/json' \
--data '
{
"user_company_token": "uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6"
}
'import requests
url = "https://api.fluid.app/api/user_companies/token_exchange"
payload = { "user_company_token": "uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6" }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({user_company_token: 'uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6'})
};
fetch('https://api.fluid.app/api/user_companies/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.fluid.app/api/user_companies/token_exchange",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'user_company_token' => 'uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6'
]),
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.fluid.app/api/user_companies/token_exchange"
payload := strings.NewReader("{\n \"user_company_token\": \"uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.fluid.app/api/user_companies/token_exchange")
.header("Content-Type", "application/json")
.body("{\n \"user_company_token\": \"uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/user_companies/token_exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_company_token\": \"uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6\"\n}"
response = http.request(request)
puts response.read_body{
"jwt": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}⌘I
Exchange user company token for JWT
curl --request PUT \
--url https://api.fluid.app/api/user_companies/token_exchange \
--header 'Content-Type: application/json' \
--data '
{
"user_company_token": "uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6"
}
'import requests
url = "https://api.fluid.app/api/user_companies/token_exchange"
payload = { "user_company_token": "uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6" }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({user_company_token: 'uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6'})
};
fetch('https://api.fluid.app/api/user_companies/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.fluid.app/api/user_companies/token_exchange",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'user_company_token' => 'uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6'
]),
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.fluid.app/api/user_companies/token_exchange"
payload := strings.NewReader("{\n \"user_company_token\": \"uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.fluid.app/api/user_companies/token_exchange")
.header("Content-Type", "application/json")
.body("{\n \"user_company_token\": \"uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/user_companies/token_exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_company_token\": \"uc_2b9f4a7c1d6e8f03a1b2c3d4e5f6\"\n}"
response = http.request(request)
puts response.read_body{
"jwt": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}