Ana içeriğe geç

POST /api/v1/auth/get-token

JWT token üretir. Her imzalama işlemi için yeni token alınmalıdır.

Request

Method: POST

URL: https://api.signaport.com/api/v1/auth/get-token

Headers:

Content-Type: application/json

Body:

{
"licenseKey": "string",
"password": "string",
"imzaTipi": 0
}

Parametreler

AlanTipZorunluAçıklama
licenseKeystringEvetFirma lisans anahtarı
passwordstringEvetLisans şifresi
imzaTipiintegerEvet0=Medula, 1=İBYS

Response

Başarılı (200 OK)

{
"success": true,
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"signToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"accessExpiresIn": 900,
"signExpiresIn": 300,
"remainingQuota": 1000
}

Response Alanları:

AlanTipAçıklama
successbooleanİşlem durumu
accessTokenstringErişim token'ı (15 dakika geçerli)
signTokenstringİmza token'ı (5 dakika geçerli, tek kullanımlık)
accessExpiresInintegerAccess token süresi (saniye)
signExpiresInintegerSign token süresi (saniye)
remainingQuotaintegerKalan imza hakkı

Hata Yanıtları

400 Bad Request - Geçersiz Parametre

{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Geçersiz istek parametreleri"
}
}

401 Unauthorized - Yanlış Kimlik Bilgileri

{
"success": false,
"error": {
"code": "INVALID_CREDENTIALS",
"message": "Geçersiz lisans bilgileri"
}
}

400 Bad Request - Kontör Yetersiz

{
"success": false,
"error": {
"code": "INSUFFICIENT_QUOTA",
"message": "İmza kotası yetersiz"
}
}

401 Unauthorized - Lisans Süresi Dolmuş

{
"success": false,
"error": {
"code": "LICENSE_EXPIRED",
"message": "Lisans süresi dolmuş"
}
}

401 Unauthorized - Lisans Pasif

{
"success": false,
"error": {
"code": "LICENSE_INACTIVE",
"message": "Lisans aktif değil"
}
}

Örnekler

cURL

curl -X POST https://api.signaport.com/api/v1/auth/get-token \
-H "Content-Type: application/json" \
-d '{
"licenseKey": "TEST-KEY-12345",
"password": "your-password",
"imzaTipi": 0
}'

JavaScript (Fetch)

const response = await fetch('https://api.signaport.com/api/v1/auth/get-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
licenseKey: 'TEST-KEY-12345',
password: 'your-password',
imzaTipi: 0
})
});

const data = await response.json();

if (data.success) {
console.log('Sign Token:', data.signToken);
console.log('Kalan Kontör:', data.remainingQuota);
} else {
console.error('Hata:', data.error.message);
}

JavaScript (Axios)

const axios = require('axios');

try {
const response = await axios.post('https://api.signaport.com/api/v1/auth/get-token', {
licenseKey: 'TEST-KEY-12345',
password: 'your-password',
imzaTipi: 0
});

console.log('Sign Token:', response.data.signToken);
console.log('Kalan Kontör:', response.data.remainingQuota);

} catch (error) {
console.error('Hata:', error.response.data.error.message);
}

C#

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

public async Task<TokenResponse> GetToken()
{
var httpClient = new HttpClient();

var request = new
{
licenseKey = "TEST-KEY-12345",
password = "your-password",
imzaTipi = 0
};

var content = new StringContent(
JsonConvert.SerializeObject(request),
Encoding.UTF8,
"application/json"
);

var response = await httpClient.PostAsync(
"https://api.signaport.com/api/v1/auth/get-token",
content
);

var responseData = await response.Content.ReadAsStringAsync();
var tokenResponse = JsonConvert.DeserializeObject<TokenResponse>(responseData);

if (tokenResponse.Success)
{
Console.WriteLine($"Sign Token: {tokenResponse.SignToken}");
Console.WriteLine($"Kalan Kontör: {tokenResponse.RemainingQuota}");
}
else
{
Console.WriteLine($"Hata: {tokenResponse.Error.Message}");
}

return tokenResponse;
}

public class TokenResponse
{
public bool Success { get; set; }
public string AccessToken { get; set; }
public string SignToken { get; set; }
public int AccessExpiresIn { get; set; }
public int SignExpiresIn { get; set; }
public int RemainingQuota { get; set; }
public ErrorInfo Error { get; set; }
}

public class ErrorInfo
{
public string Code { get; set; }
public string Message { get; set; }
}

PHP

<?php

$data = [
'licenseKey' => 'TEST-KEY-12345',
'password' => 'your-password',
'imzaTipi' => 0
];

$ch = curl_init('https://api.signaport.com/api/v1/auth/get-token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$result = json_decode($response, true);

if ($result['success']) {
echo "Sign Token: " . $result['signToken'] . "\n";
echo "Kalan Kontör: " . $result['remainingQuota'] . "\n";
} else {
echo "Hata: " . $result['error']['message'] . "\n";
}

?>

Python

import requests
import json

url = 'https://api.signaport.com/api/v1/auth/get-token'
headers = {'Content-Type': 'application/json'}
data = {
'licenseKey': 'TEST-KEY-12345',
'password': 'your-password',
'imzaTipi': 0
}

response = requests.post(url, headers=headers, data=json.dumps(data))
result = response.json()

if result['success']:
print(f"Sign Token: {result['signToken']}")
print(f"Kalan Kontör: {result['remainingQuota']}")
else:
print(f"Hata: {result['error']['message']}")

Notlar

  • Her imzalama işlemi için yeni token alınmalıdır
  • signToken 5 dakika geçerlidir
  • signToken tek kullanımlıktır (kullanıldıktan sonra geçersiz olur)
  • accessToken genel API erişimi içindir (şu an kullanılmıyor)
  • password hash'lenerek saklanır, plain text gönderilir
  • HTTPS kullanımı zorunludur

Rate Limiting

Bu endpoint için dakika başına maksimum 10 istek yapılabilir.

Limit aşıldığında HTTP 429 döner:

{
"success": false,
"message": "Çok fazla istek. Lütfen bekleyiniz.",
"retryAfter": 45
}