curl --request POST \
--url http://localhost:8090/internal/v1/connections/{connection_id}/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": []
}'import requests
url = "http://localhost:8090/internal/v1/connections/{connection_id}/api-keys"
payload = { "scopes": [] }
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({scopes: []})
};
fetch('http://localhost:8090/internal/v1/connections/{connection_id}/api-keys', 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/{connection_id}/api-keys",
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([
'scopes' => [
]
]),
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/{connection_id}/api-keys"
payload := strings.NewReader("{\n \"scopes\": []\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/{connection_id}/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"scopes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8090/internal/v1/connections/{connection_id}/api-keys")
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 \"scopes\": []\n}"
response = http.request(request)
puts response.read_body{
"api_key_id": "<string>",
"connection_id": "<string>",
"scopes": [
"catalog:read"
],
"created_at": "2023-11-07T05:31:56Z",
"revoked_at": "2023-11-07T05:31:56Z",
"secret": "<string>"
}Emitir una clave de storefront
El connection_id va en la ruta y se valida contra el control plane antes de emitir. El backend lo saca del usuario de su sesión, pero esta superficie no le cree y lo comprueba igual: un merchant no puede pedir claves de otra tienda ni por un bug del backend.
El cuerpo es opcional: ausente, {} o {"scopes": []} emiten los tres.
curl --request POST \
--url http://localhost:8090/internal/v1/connections/{connection_id}/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": []
}'import requests
url = "http://localhost:8090/internal/v1/connections/{connection_id}/api-keys"
payload = { "scopes": [] }
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({scopes: []})
};
fetch('http://localhost:8090/internal/v1/connections/{connection_id}/api-keys', 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/{connection_id}/api-keys",
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([
'scopes' => [
]
]),
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/{connection_id}/api-keys"
payload := strings.NewReader("{\n \"scopes\": []\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/{connection_id}/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"scopes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8090/internal/v1/connections/{connection_id}/api-keys")
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 \"scopes\": []\n}"
response = http.request(request)
puts response.read_body{
"api_key_id": "<string>",
"connection_id": "<string>",
"scopes": [
"catalog:read"
],
"created_at": "2023-11-07T05:31:56Z",
"revoked_at": "2023-11-07T05:31:56Z",
"secret": "<string>"
}Autorizaciones
crossup-backend, actuando por la sesión de panel de un merchant (ADR 0010). Su superficie son las tres rutas de claves de storefront de una conexión y nada más.
Parámetros de ruta
La conexión de CrossUp.
1Cuerpo
scopes es opcional: omitido, vacío, o el cuerpo entero ausente, emiten los tres. Un scope fuera del set es 422 y no 400 — el JSON estaba bien, lo que no existe es el permiso.
El set cerrado de scopes de una clave spk_ (CHECK de la migración 0012).
catalog:read, recommendations:read, signals:write Respuesta
La clave nueva, con su valor en claro.
Una clave como la ve el merchant. secret viaja en claro a propósito (ADR 0010): la clave vive en el navegador de cada comprador, así que ocultársela a su dueño no agrega seguridad. Se omite en las claves anteriores a la migración 0013, que sólo existieron como digest.
11El set cerrado de scopes de una clave spk_ (CHECK de la migración 0012).
catalog:read, recommendations:read, signals:write Siempre null en el listado, que devuelve sólo las activas. Está en el contrato igual para que la forma no cambie el día que se muestre el histórico.
1