cURL
curl --request POST \
--url https://sandbox-api.superpagamentos.com/auth \
--header 'Content-Type: application/json' \
--data '
{
"publicKey": "SP-PublicKey",
"privateKey": "SP-SecretKey"
}
'import requests
url = "https://sandbox-api.superpagamentos.com/auth"
payload = {
"publicKey": "SP-PublicKey",
"privateKey": "SP-SecretKey"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({publicKey: 'SP-PublicKey', privateKey: 'SP-SecretKey'})
};
fetch('https://sandbox-api.superpagamentos.com/auth', 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://sandbox-api.superpagamentos.com/auth",
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([
'publicKey' => 'SP-PublicKey',
'privateKey' => 'SP-SecretKey'
]),
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://sandbox-api.superpagamentos.com/auth"
payload := strings.NewReader("{\n \"publicKey\": \"SP-PublicKey\",\n \"privateKey\": \"SP-SecretKey\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://sandbox-api.superpagamentos.com/auth")
.header("Content-Type", "application/json")
.body("{\n \"publicKey\": \"SP-PublicKey\",\n \"privateKey\": \"SP-SecretKey\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox-api.superpagamentos.com/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"publicKey\": \"SP-PublicKey\",\n \"privateKey\": \"SP-SecretKey\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"access_token": "<access_token>",
"refresh_token": "<refresh_token>",
"expires_in": "3600s"
},
"message": "Usuário autenticado com sucesso"
}Autenticação
Autenticar conta
A rota /auth gera tokens JWT com duração de 3600 segundos. Com esses tokens é possível autenticar as demais rotas da aplicação para.
Recomenda-se nunca armazenar as chaves em ambientes front-end, sempre utilizar em ambientes protegidos por um certificado SSL e NUNCA compartilhar suas credenciais com outras pessoas (nem mesmo do Suporte da Super).
POST
/
auth
cURL
curl --request POST \
--url https://sandbox-api.superpagamentos.com/auth \
--header 'Content-Type: application/json' \
--data '
{
"publicKey": "SP-PublicKey",
"privateKey": "SP-SecretKey"
}
'import requests
url = "https://sandbox-api.superpagamentos.com/auth"
payload = {
"publicKey": "SP-PublicKey",
"privateKey": "SP-SecretKey"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({publicKey: 'SP-PublicKey', privateKey: 'SP-SecretKey'})
};
fetch('https://sandbox-api.superpagamentos.com/auth', 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://sandbox-api.superpagamentos.com/auth",
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([
'publicKey' => 'SP-PublicKey',
'privateKey' => 'SP-SecretKey'
]),
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://sandbox-api.superpagamentos.com/auth"
payload := strings.NewReader("{\n \"publicKey\": \"SP-PublicKey\",\n \"privateKey\": \"SP-SecretKey\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://sandbox-api.superpagamentos.com/auth")
.header("Content-Type", "application/json")
.body("{\n \"publicKey\": \"SP-PublicKey\",\n \"privateKey\": \"SP-SecretKey\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox-api.superpagamentos.com/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"publicKey\": \"SP-PublicKey\",\n \"privateKey\": \"SP-SecretKey\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"access_token": "<access_token>",
"refresh_token": "<refresh_token>",
"expires_in": "3600s"
},
"message": "Usuário autenticado com sucesso"
}Body
application/json
Gere um token de autenticação JWT (Json Web Tokens) com duração de 3600s utilizando a sua Public Key e Secret Key. Esse token será utilizado para autenticar as demais APIs.
⌘I