Obter token de acesso
curl --request POST \
--url https://api-payment.safefypay.com.br/v1/auth/token \
--header 'Content-Type: application/json' \
--data '
{
"publicKey": "pk_sandbox_abc123def456",
"secretKey": "sk_sandbox_xyz789ghi012"
}
'import requests
url = "https://api-payment.safefypay.com.br/v1/auth/token"
payload = {
"publicKey": "pk_sandbox_abc123def456",
"secretKey": "sk_sandbox_xyz789ghi012"
}
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: 'pk_sandbox_abc123def456', secretKey: 'sk_sandbox_xyz789ghi012'})
};
fetch('https://api-payment.safefypay.com.br/v1/auth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-payment.safefypay.com.br/v1/auth/token"
payload := strings.NewReader("{\n \"publicKey\": \"pk_sandbox_abc123def456\",\n \"secretKey\": \"sk_sandbox_xyz789ghi012\"\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://api-payment.safefypay.com.br/v1/auth/token")
.header("Content-Type", "application/json")
.body("{\n \"publicKey\": \"pk_sandbox_abc123def456\",\n \"secretKey\": \"sk_sandbox_xyz789ghi012\"\n}")
.asString();{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"tokenType": "Bearer",
"expiresIn": 3600,
"environment": "Sandbox"
},
"message": null,
"error": null
}{
"data": null,
"message": null,
"error": {
"message": "O campo publicKey e obrigatorio.",
"code": "validation_error"
}
}{
"data": null,
"message": null,
"error": {
"message": "Credenciais invalidas ou inativas.",
"code": "invalid_credentials"
}
}{
"data": null,
"message": null,
"error": {
"message": "Limite de geracao de tokens excedido (10/hora).",
"code": "rate_limit_exceeded"
}
}Autenticação
Gerar token
Autenticação OAuth2 - Client Credentials
POST
/
v1
/
auth
/
token
Obter token de acesso
curl --request POST \
--url https://api-payment.safefypay.com.br/v1/auth/token \
--header 'Content-Type: application/json' \
--data '
{
"publicKey": "pk_sandbox_abc123def456",
"secretKey": "sk_sandbox_xyz789ghi012"
}
'import requests
url = "https://api-payment.safefypay.com.br/v1/auth/token"
payload = {
"publicKey": "pk_sandbox_abc123def456",
"secretKey": "sk_sandbox_xyz789ghi012"
}
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: 'pk_sandbox_abc123def456', secretKey: 'sk_sandbox_xyz789ghi012'})
};
fetch('https://api-payment.safefypay.com.br/v1/auth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-payment.safefypay.com.br/v1/auth/token"
payload := strings.NewReader("{\n \"publicKey\": \"pk_sandbox_abc123def456\",\n \"secretKey\": \"sk_sandbox_xyz789ghi012\"\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://api-payment.safefypay.com.br/v1/auth/token")
.header("Content-Type", "application/json")
.body("{\n \"publicKey\": \"pk_sandbox_abc123def456\",\n \"secretKey\": \"sk_sandbox_xyz789ghi012\"\n}")
.asString();{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"tokenType": "Bearer",
"expiresIn": 3600,
"environment": "Sandbox"
},
"message": null,
"error": null
}{
"data": null,
"message": null,
"error": {
"message": "O campo publicKey e obrigatorio.",
"code": "validation_error"
}
}{
"data": null,
"message": null,
"error": {
"message": "Credenciais invalidas ou inativas.",
"code": "invalid_credentials"
}
}{
"data": null,
"message": null,
"error": {
"message": "Limite de geracao de tokens excedido (10/hora).",
"code": "rate_limit_exceeded"
}
}Use este endpoint para obter o
accessToken JWT e autenticar as demais requisições.
Este endpoint possui limite de 10 gerações de token por hora por credencial.
Se exceder, a API retorna
429 com código auth_rate_limit_exceeded.O ambiente retornado (
Sandbox ou Production) é determinado automaticamente pelas credenciais utilizadas.Corpo
application/json