Authentication API
The Authentication API allows you to securely access your application's resources. To perform authentication, you need to provide an API key and a secret.
Login Endpoint
https://sandbox.tickpay.com/api/v1/auth/login
Request
Use the following cURL command to authenticate and obtain an access token:
- cURL
- C#
- JavaScript
- Python
- Java
- PHP
curl -X 'POST' \
'https://sandbox.tickpay.com/api/v1/auth/login' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"apiKey": "your_key",
"apiSecret": "your_secret"
}'
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using (HttpClient client = new HttpClient())
{
string apiUrl = "https://sandbox.tickpay.com/api/v1/auth/login";
string jsonData = "{\"apiKey\":\"your_key\", \"apiSecret\":\"your_secret\"}";
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
using (HttpResponseMessage response = await client.PostAsync(apiUrl, content))
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
}
}
const url = 'https://sandbox.tickpay.com/api/v1/auth/login';
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
};
const data = {
'apiKey': 'your_key',
'apiSecret': 'your_secret'
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
console.log('Resposta do servidor:', data);
})
.catch(error => {
console.error('Erro na requisição:', error);
});
import requests
url = 'https://sandbox.tickpay.com/api/v1/auth/login'
headers = {'accept': 'application/json', 'Content-Type': 'application/json'}
data = {'apiKey': 'your_key', 'apiSecret': 'your_secret'}
response = requests.post(url, json=data, headers=headers)
print(response.json())
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Map;
public class Example {
public static void main(String[] args) {
HttpClient httpClient = HttpClient.newHttpClient();
String url = "https://sandbox.tickpay.com/api/v1/auth/login";
Map<String, String> headers = Map.of(
"accept", "application/json",
"Content-Type", "application/json"
);
String jsonData = "{\"apiKey\":\"your_key\", \"apiSecret\":\"your_secret\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.flatMap(e -> Map.entry(e.getKey(), e.getValue()).stream())
.toArray(String[]::new))
.POST(BodyPublishers.ofString(jsonData))
.build();
try {
HttpResponse<String> response = httpClient.send(request, BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$apiUrl = "https://sandbox.tickpay.com/api/v1/auth/login";
$jsonData = json_encode(["apiKey" => "your_key", "apiSecret" => "your_secret"]);
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
}
curl_close($ch);
echo $result;
?>
Request body
| Parameter | Description | Required |
|---|---|---|
apiKey | API key for authentication. | true |
apiSecret | API secret for authentication. | true |
Response
The response will contain a data object with an accessToken property, along with additional information:
{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzY2RmMmQxLWE0M2YtNDFiMi05M2VhLTE0NmE2ODVjOGZlOSIsInJvbGUiOiJjbGllbnQiLCJpYXQiOjE3MDQ2Nzk5NjcsImV4cCI6MTcwNDY4MzU2N30.NahxV_-CFt86SpnNvXyEdrdpNkn6TGC4UJdlG2ZRNDE"
},
"messageError": null,
"success": true
}
Response Properties
| Parameter | Description | Default Value |
|---|---|---|
data | Object containing response data. | null |
accessToken | The generated access token. | null |
messageError | Error message. | null |
success | Indicates whether the request was successful. | false |