Ana içeriğe geç

Kimlik Doğrulama

Integration API, JWT tabanlı access token ve refresh token ile API Key/Secret Key kimlik doğrulaması kullanır.

Kimlik Doğrulama Akışı​

  1. API Kimlik Bilgilerini Alın: Brokerage platformundan API Key ve Secret Key'inizi alın
  2. Kimlik Doğrulayın: Kimlik bilgilerinizi kullanarak access token ve refresh token alın
  3. Access Token Kullanın: API isteklerinde Authorization header'ında access token'ı ekleyin
  4. Token Yenileyin: Access token süresi dolduğunda, refresh token kullanarak yeni bir access token alın

Kimlik Doğrulama​

API key ve secret key'inizle kimlik doğrulayarak access ve refresh token alın.

Endpoint: POST /api/v1/integration/auth/authenticate

İstek​

Kimlik bilgilerini istek gövdesinde veya header'larda gönderebilirsiniz:

Gerekli Header:

X-Target-Server: authentication

Seçenek 1: İstek Gövdesi

{
"api_key": "your-api-key",
"secret_key": "your-secret-key"
}

Seçenek 2: Header'lar

Api-Key: your-api-key
Api-Secret: your-secret-key

Örnek cURL İsteği​

Seçenek 1: İstek Gövdesi

curl -X POST https://<base-url>/api/v1/integration/auth/authenticate \
-H "Content-Type: application/json" \
-H "X-Target-Server: authentication" \
-d '{
"api_key": "your-api-key",
"secret_key": "your-secret-key"
}'

Seçenek 2: Header'lar

curl -X POST https://<base-url>/api/v1/integration/auth/authenticate \
-H "X-Target-Server: authentication" \
-H "Api-Key: your-api-key" \
-H "Api-Secret: your-secret-key"

Yanıt​

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "abc123def456...",
"token_type": "Bearer",
"expires_in": 3600,
"expires_at": "2025-01-03T12:00:00Z"
}

Yanıt Alanları​

  • access_token: API kimlik doğrulaması için JWT token (1 saat geçerli)
  • refresh_token: Access token'ı yenilemek için token (7 gün geçerli)
  • token_type: Her zaman "Bearer"
  • expires_in: Access token süre dolumu saniye cinsinden (3600 = 1 saat)
  • expires_at: Access token süre dolumu zaman damgası

Access Token Kullanımı​

Tüm korumalı endpoint'ler için Authorization header'ında access token'ı ekleyin. Ayrıca X-Target-Server header'ını da ekleyin:

Authorization: Bearer <access_token>
X-Target-Server: integration

Örnek cURL İsteği​

curl -X GET https://<base-url>/api/v1/integration/<endpoint> \
-H "Authorization: Bearer <access_token>" \
-H "X-Target-Server: integration"

Not: Kimlik doğrulama endpoint'leri (/auth/authenticate ve /auth/refresh) X-Target-Server: authentication kullanırken, diğer tüm endpoint'ler X-Target-Server: integration kullanır.

Token Yenileme​

Access token süresi dolduğunda token'ınızı yenileyin.

Endpoint: POST /api/v1/integration/auth/refresh

İstek​

Gerekli Header:

X-Target-Server: authentication
{
"refresh_token": "abc123def456..."
}

Örnek cURL İsteği​

curl -X POST https://<base-url>/api/v1/integration/auth/refresh \
-H "Content-Type: application/json" \
-H "X-Target-Server: authentication" \
-d '{
"refresh_token": "abc123def456..."
}'

Yanıt​

Kimlik doğrulama endpoint'i ile aynı format, yeni bir access token ve aynı refresh token döndürür.

Hata Yanıtları​

Geçersiz Kimlik Bilgileri (401)​

{
"error": {
"code": "INVALID_API_KEY",
"message": "invalid api key or secret"
}
}

Süresi Dolmuş Refresh Token (401)​

{
"error": {
"code": "REFRESH_TOKEN_EXPIRED",
"message": "refresh token expired"
}
}

Webhook Kimlik Doğrulama Tipleri​

Webhook'ları yapılandırırken (market'ler, distributor'lar vb. için), authentication objesi içindeki type alanını kullanarak kimlik doğrulama tipini belirtebilirsiniz.

Kimlik Doğrulama Tipi Değerleri​

TipDeğerAçıklama
Basic1Kullanıcı adı ve şifre kullanan HTTP Basic Authentication
Token2Token tabanlı kimlik doğrulama

Örnek: Basic Authentication​

{
"authentication": {
"type": 1,
"username": "user",
"password": "pass"
}
}

Örnek: Token Authentication​

{
"authentication": {
"type": 2,
"token": "your-token-here"
}
}