> For the complete documentation index, see [llms.txt](https://docs.iyzico.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iyzico.com/urunler/fiziksel-pos/terminal-api-entegrasyonu/login-islemleri.md).

# Login İşlemleri

Terminal API servislerine erişim sağlamak için iyzico OAuth2 kimlik doğrulama yapısı kullanılmaktadır.

Entegrasyon sürecinde öncelikle login işlemi gerçekleştirilir ve ardından access token alınır.\
Alınan access token, tüm servis çağrılarında Authorization header içerisinde kullanılır.

{% hint style="info" %}
Not:\
Login ve access token alma adımları, hem VUK 507 hem de VUK 509 entegrasyonları için ortaktır.
{% endhint %}

#### Login Akışı

```
1. Login → kullanıcı doğrulanır
2. Token alma → access_token üretilir
3. Servis çağrıları → Bearer token ile yapılır
```

### Kullanıcı Doğrulama ve Yetkilendirme (Authorize) Başlatma

## POST /in-store/oauth2/authorize

> Bu servis authorization aşamasını başlatır ve "auth code" üretir.\
> \
> Akış:\
> 1\) Bu servise form-urlencoded body ile istek atılır.\
> 2\) Yanıttaki "code" değeri alınır.\
> 3\) Alınan "code" değeri, token üretmek için "Get Token with Auth Code" servisinde kullanılır.<br>

```json
{"openapi":"3.0.3","info":{"title":"Terminal API – Outside Flow","version":"1.0.3"},"tags":[{"name":"OAuth"}],"servers":[{"url":"https://api.iyzipay.com"},{"url":"https://sandbox-api.iyzipay.com"}],"paths":{"/in-store/oauth2/authorize":{"post":{"tags":["OAuth"],"description":"Bu servis authorization aşamasını başlatır ve \"auth code\" üretir.\n\nAkış:\n1) Bu servise form-urlencoded body ile istek atılır.\n2) Yanıttaki \"code\" değeri alınır.\n3) Alınan \"code\" değeri, token üretmek için \"Get Token with Auth Code\" servisinde kullanılır.\n","requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/OAuthAuthorizeRequest"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthAuthorizeResponse"}}}},"401":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthAuthorizeErrorResponse"}}}}}}}},"components":{"schemas":{"OAuthAuthorizeRequest":{"type":"object","required":["scope","client_id","client_secret","response_type","username","password","request_timestamp"],"properties":{"scope":{"type":"string","description":"Default değer: iyzipayApiGateway","enum":["iyzipayApiGateway"]},"client_id":{"type":"string","description":"iyzico tarafından sağlanan merchant özelinde clientid değeri."},"client_secret":{"type":"string","description":"iyzico tarafından üretilen merchant özelinde client secret değeri."},"response_type":{"type":"string","description":"Default değer; code","enum":["code"]},"username":{"type":"string","description":"Kullanıcı Adı"},"password":{"type":"string","description":"Kullanıcı şifre"},"request_timestamp":{"type":"string","description":"İlgili requestin gönderildiği unix timestamp değeri."}}},"OAuthAuthorizeResponse":{"type":"object","properties":{"code":{"type":"string","description":"Auth Code"},"issuedAt":{"type":"string","description":"İşlem tarihi"},"expiredAt":{"type":"string","description":"İşlem geçerlilik tarihi"}}},"OAuthAuthorizeErrorResponse":{"type":"object","properties":{"errorCode":{"type":"string","description":"Hata Kodu"},"description":{"type":"string","description":"Hata Açıklaması"},"uri":{"type":"string","description":"Bazı durumlarda dönen"}}}}}}
```

### Örnek Collection

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/47010871-736de0b5-c39a-4c8e-8c9f-626b4ce8414a">Postman</a></td></tr></tbody></table>

### Get Token with Auth Code / Refresh Token

## POST /in-store/oauth2/token

> Bu servis, auth code kullanarak access\_token ve refresh\_token üretir.\
> \
> Authorization (Basic Auth):\
> \- Username: client\_id\
> \- Password: client\_secret\
> Header formatı:\
> Authorization: Basic base64(client\_id:client\_secret)\
> \
> Akış (Auth Code):\
> 1\) /authorize çağrısından dönen "code" alınır.\
> 2\) Bu servise form-urlencoded body ile gönderilir:\
> &#x20;  \- grant\_type=authorization\_code\
> &#x20;  \- code={authCode}\
> 3\) Response içinden:\
> &#x20;  \- access\_token: Terminal Host servislerinde Bearer Token olarak kullanılır.\
> &#x20;  \- refresh\_token: Token yenileme için saklanır.\
> &#x20;  \- expires\_in: access\_token geçerlilik süresi (sn).<br>

```json
{"openapi":"3.0.3","info":{"title":"Terminal API – Outside Flow","version":"1.0.3"},"tags":[{"name":"OAuth"}],"servers":[{"url":"https://api.iyzipay.com"},{"url":"https://sandbox-api.iyzipay.com"}],"security":[{"BasicAuth":[]}],"components":{"securitySchemes":{"BasicAuth":{"type":"http","scheme":"basic","description":"Basic Auth ile yetkilendirme.\nPostman Basic Auth alanları:\n- Username: client_id\n- Password: client_secret\n\nHTTP header karşılığı:\nAuthorization: Basic base64(client_id:client_secret)\n"}},"schemas":{"OAuthTokenRequestAuthCode":{"type":"object","required":["grant_type","code"],"description":"Authorization Code ile ile JWT token üretir. client_id ve client_secret ile Basic Auth yapılır.","properties":{"grant_type":{"type":"string","description":"Token Üretilecek İşlem Türü","enum":["authorization_code","refresh_token"]},"code":{"type":"string","description":"Authorization aşamasında üretilen authCode değeri."}}},"OAuthTokenRequestRefresh":{"type":"object","required":["grant_type","refresh_token"],"description":"Refresh Token ile JWT token üretir. client_id ve client_secret ile Basic Auth yapılır.","properties":{"grant_type":{"type":"string","description":"Token Üretilecek İşlem Türü","enum":["authorization_code","refresh_token"]},"refresh_token":{"type":"string","description":"Token yenileme işlemi için kullanılacak refresh token değeri."}}},"OAuthTokenResponse":{"type":"object","properties":{"access_token":{"type":"string","description":"Access Token Değeri"},"refresh_token":{"type":"string","description":"Refresh Token Değeri"},"scope":{"type":"string","description":"Default Scope Değeri","enum":["iyzipayApiGateway"]},"token_type":{"type":"string","description":"Authoraztion da kullanılan token tipi"},"expires_in":{"type":"integer","format":"int32","description":"Saniye bazında geçerlilik süresi."}}},"OAuthSimpleError":{"type":"object","properties":{"error":{"type":"string","description":""}}}}},"paths":{"/in-store/oauth2/token":{"post":{"tags":["OAuth"],"description":"Bu servis, auth code kullanarak access_token ve refresh_token üretir.\n\nAuthorization (Basic Auth):\n- Username: client_id\n- Password: client_secret\nHeader formatı:\nAuthorization: Basic base64(client_id:client_secret)\n\nAkış (Auth Code):\n1) /authorize çağrısından dönen \"code\" alınır.\n2) Bu servise form-urlencoded body ile gönderilir:\n   - grant_type=authorization_code\n   - code={authCode}\n3) Response içinden:\n   - access_token: Terminal Host servislerinde Bearer Token olarak kullanılır.\n   - refresh_token: Token yenileme için saklanır.\n   - expires_in: access_token geçerlilik süresi (sn).\n","requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"oneOf":[{"$ref":"#/components/schemas/OAuthTokenRequestAuthCode"},{"$ref":"#/components/schemas/OAuthTokenRequestRefresh"}]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthTokenResponse"}}}},"400":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthSimpleError"}}}},"401":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthSimpleError"}}}}}}}}}
```

### Örnek Collection

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/47010871-e6a71b90-907e-45f2-9968-8c6f87c47040">Auth Code</a></td></tr><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/47010871-1898d0c7-82ce-4b9b-ab89-d00d2fe42a3f">Refresh Token</a></td></tr></tbody></table>

{% hint style="warning" %}
Access token belirli bir süre için geçerlidir. Süresi dolan token ile yapılan isteklerde yetkilendirme hatası alınır.\
Bu durumda yeniden login yapılarak yeni token alınmalıdır.
{% endhint %}
