Initiate OAuth connection - Barndoor Documentation
Initiate OAuth connection
cURL
curl --request POST \
--url https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'
Python
import requests
url = "https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect",
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([]),
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;
}
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect"
payload := strings.NewReader("")
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))
}
Unirest (Java)
HttpResponse<String> response = Unirest.post("https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://your-org.platform.barndoor.ai/api/servers/{server_id}/connect")
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 = "{}"
response = http.request(request)
puts response.read_body
HTTP Response Codes
- 200
- 401
- 404
- 500
Example JSON Responses
Successful Authorization
{
"auth_url": "https://login.salesforce.com/services/oauth2/authorize?..."
}
Server Not Found
{
"error": "ServerNotFound",
"message": "Server with ID '123' not found",
"details": {}
}
OAuth Configuration Error
{
"error": "OAuthConfigurationError",
"message": "Server is missing OAuth configuration. Ask an admin to configure credentials before initiating a connection."
}
Authorizations
Authorizationstringheader
required
JWT token obtained through Barndoor's OAuth 2.0 authorization-code flow with PKCE. The token should be included in the Authorization header: Authorization: Bearer <your-jwt-token>.
Use the Barndoor SDK's loginInteractive() function to obtain tokens automatically.
Path Parameters
server_id
string
required
Server UUID
Query Parameters
return_url
string
Optional return URL after OAuth completion
Body
application/json
The body is of type object.
Response
- 200
application/json
Connection initiation successfulauth_url
string
OAuth authorization URL to redirect user toExample:
`