Get Session
curl --request GET \
--url https://api.centralcart.io/v1/webstore/auth/session \
--header 'Authorization: Bearer <token>' \
--header 'x-store-domain: <x-store-domain>'import requests
url = "https://api.centralcart.io/v1/webstore/auth/session"
headers = {
"x-store-domain": "<x-store-domain>",
"Authorization": "Bearer <token>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'x-store-domain': '<x-store-domain>', Authorization: 'Bearer <token>'}
};
fetch('https://api.centralcart.io/v1/webstore/auth/session', 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.centralcart.io/v1/webstore/auth/session",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"x-store-domain: <x-store-domain>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.centralcart.io/v1/webstore/auth/session"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-store-domain", "<x-store-domain>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.centralcart.io/v1/webstore/auth/session")
.header("x-store-domain", "<x-store-domain>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.centralcart.io/v1/webstore/auth/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-store-domain"] = '<x-store-domain>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"customer": {
"email": "[email protected]",
"name": "João",
"avatar": null,
"discord_id": null,
"stats": {
"orders_count": 5,
"approved_orders_count": 4,
"total_spent": 189.6,
"first_order_at": "2024-01-10T12:04:55.000-03:00",
"last_order_at": "2024-03-03T23:43:12.000-03:00"
}
}
}{
"errors": [
{
"message": "Sessão inválida ou expirada.",
"code": "CUSTOMER_UNAUTHENTICATED"
}
]
}Autenticação
Get Session
Dados do comprador autenticado.
Use para saber se a sessão ainda vale e para montar o cabeçalho da conta.
GET
/
webstore
/
auth
/
session
Get Session
curl --request GET \
--url https://api.centralcart.io/v1/webstore/auth/session \
--header 'Authorization: Bearer <token>' \
--header 'x-store-domain: <x-store-domain>'import requests
url = "https://api.centralcart.io/v1/webstore/auth/session"
headers = {
"x-store-domain": "<x-store-domain>",
"Authorization": "Bearer <token>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'x-store-domain': '<x-store-domain>', Authorization: 'Bearer <token>'}
};
fetch('https://api.centralcart.io/v1/webstore/auth/session', 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.centralcart.io/v1/webstore/auth/session",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"x-store-domain: <x-store-domain>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.centralcart.io/v1/webstore/auth/session"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-store-domain", "<x-store-domain>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.centralcart.io/v1/webstore/auth/session")
.header("x-store-domain", "<x-store-domain>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.centralcart.io/v1/webstore/auth/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-store-domain"] = '<x-store-domain>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"customer": {
"email": "[email protected]",
"name": "João",
"avatar": null,
"discord_id": null,
"stats": {
"orders_count": 5,
"approved_orders_count": 4,
"total_spent": 189.6,
"first_order_at": "2024-01-10T12:04:55.000-03:00",
"last_order_at": "2024-03-03T23:43:12.000-03:00"
}
}
}{
"errors": [
{
"message": "Sessão inválida ou expirada.",
"code": "CUSTOMER_UNAUTHENTICATED"
}
]
}Autorizações
access_token do comprador, devolvido por POST /webstore/auth/verify. Não confunda com a chave privada da loja, que nunca deve ir para o navegador.
Cabeçalhos
Domínio da sua loja (ex: sualoja.centralcart.ai)
Resposta
Comprador autenticado
Show child attributes
Show child attributes
⌘I