curl --request POST \
--url http://localhost:8090/internal/v1/connections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"provider": "<string>",
"provider_app_id": "<string>",
"external_store_id": "<string>",
"access_token": "<string>",
"scope": "<string>"
}
'import requests
url = "http://localhost:8090/internal/v1/connections"
payload = {
"provider": "<string>",
"provider_app_id": "<string>",
"external_store_id": "<string>",
"access_token": "<string>",
"scope": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
provider: '<string>',
provider_app_id: '<string>',
external_store_id: '<string>',
access_token: '<string>',
scope: '<string>'
})
};
fetch('http://localhost:8090/internal/v1/connections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8090",
CURLOPT_URL => "http://localhost:8090/internal/v1/connections",
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' => '<string>',
'provider_app_id' => '<string>',
'external_store_id' => '<string>',
'access_token' => '<string>',
'scope' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8090/internal/v1/connections"
payload := strings.NewReader("{\n \"provider\": \"<string>\",\n \"provider_app_id\": \"<string>\",\n \"external_store_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"scope\": \"<string>\"\n}")
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))
}HttpResponse<String> response = Unirest.post("http://localhost:8090/internal/v1/connections")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"<string>\",\n \"provider_app_id\": \"<string>\",\n \"external_store_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"scope\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8090/internal/v1/connections")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"provider\": \"<string>\",\n \"provider_app_id\": \"<string>\",\n \"external_store_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"scope\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"connection_id": "<string>",
"webhook_endpoint_id": "<string>",
"created": true
}{
"connection_id": "<string>",
"webhook_endpoint_id": "<string>",
"created": true
}Registrar o reinstalar una conexión de plataforma
El camino corto del alta: cifra la credencial y registra la conexión en una transacción. Una reinstalación conserva conexión y endpoint, reemplaza la credencial y reescribe scopes y capabilities con lo que el merchant concedió esta vez — por eso contesta 200 y no 201.
curl --request POST \
--url http://localhost:8090/internal/v1/connections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"provider": "<string>",
"provider_app_id": "<string>",
"external_store_id": "<string>",
"access_token": "<string>",
"scope": "<string>"
}
'import requests
url = "http://localhost:8090/internal/v1/connections"
payload = {
"provider": "<string>",
"provider_app_id": "<string>",
"external_store_id": "<string>",
"access_token": "<string>",
"scope": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
provider: '<string>',
provider_app_id: '<string>',
external_store_id: '<string>',
access_token: '<string>',
scope: '<string>'
})
};
fetch('http://localhost:8090/internal/v1/connections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8090",
CURLOPT_URL => "http://localhost:8090/internal/v1/connections",
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' => '<string>',
'provider_app_id' => '<string>',
'external_store_id' => '<string>',
'access_token' => '<string>',
'scope' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8090/internal/v1/connections"
payload := strings.NewReader("{\n \"provider\": \"<string>\",\n \"provider_app_id\": \"<string>\",\n \"external_store_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"scope\": \"<string>\"\n}")
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))
}HttpResponse<String> response = Unirest.post("http://localhost:8090/internal/v1/connections")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"<string>\",\n \"provider_app_id\": \"<string>\",\n \"external_store_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"scope\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8090/internal/v1/connections")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"provider\": \"<string>\",\n \"provider_app_id\": \"<string>\",\n \"external_store_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"scope\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"connection_id": "<string>",
"webhook_endpoint_id": "<string>",
"created": true
}{
"connection_id": "<string>",
"webhook_endpoint_id": "<string>",
"created": true
}Autorizaciones
El conector de plataforma y el operador. Registra conexiones, entrega webhooks, corre la saga de instalación y da de alta conexiones custom. Es el único principal obligatorio del proceso: los otros tres se apagan dejando su token vacío, y una puerta que no se monta no la abre ningún token.
Cuerpo
connectorprotocol.RegisterConnectionRequest. provider y provider_app_id tienen que coincidir con el principal del token: el servidor no los cree, los compara (connection.go), y una diferencia es 401 y no 403.
111El token del merchant, en claro y sólo en esta llamada. Se cifra en la misma transacción que registra la conexión y nunca vuelve a salir.
1Los scopes que concedió el merchant, separados por coma o espacio.
Respuesta
La conexión ya existía; se reemplazó la credencial.