---
title: "Authentication — API başvurusu"
description: "Komut satırı araçları için tarayıcıyla giriş (cihaz yetkilendirmesi, `gh auth login` gibi) ve kullanılan anahtarın oturumu. 1) `POST /auth/device/code"
url: https://www.gyrohosting.com/developers/tr/api/authentication.html
language: tr
openapi: https://www.gyrohosting.com/developers/openapi.json
api_version: 2.31.0
---

# Authentication

Komut satırı araçları için tarayıcıyla giriş (cihaz yetkilendirmesi, `gh auth login` gibi) ve kullanılan anahtarın oturumu. 1) `POST /auth/device/code` (anahtarsız) bir `user_code` ve adres döner; 2) kullanıcı adresi açar, panele giriş yapar, kodu ve isteğin IP/istemci bilgisini kontrol eder, izinleri ve süreyi seçip onaylar; 3) araç her `interval` saniyede `POST /auth/device/token` sorgular ve yeni müşteri API anahtarını bir kez alır. Anahtar sıradan bir anahtardır: API Kimlik Bilgileri sayfasında görünür ve iptal edilebilir, izin modeli, para kuralları ve IP kilidi aynıdır. CI'da panelde ya da `POST /cloud/keys` ile oluşturulan anahtarı kullanmaya devam edin.

Base URL: `https://www.gyrohosting.com/api/v1/client` · OpenAPI: https://www.gyrohosting.com/developers/openapi.json


## POST /auth/device/code

**Tarayıcıyla girişi başlat (cihaz kodu)** · operationId `createDeviceCode` · scope `` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/createDeviceCode.json

API anahtarı gerekmez. Sınır: IP başına 10 dakikada 10 kod (429 `rate_limited`). Kod `expires_in` saniye geçerlidir. `template` / `scopes` onay sayfasındaki izinleri yalnız önceden seçer; karar kullanıcınındır.


### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `client_name` | string |  |
| `client_version` | string |  |
| `hostname` | string |  |
| `os` | string |  |
| `template` | string (readonly, dns, cloud, containers, storage, billing, full, custom) |  |
| `scopes` | array<string> |  |
| `lang` | string (tr, en) |  |

### Yanıtlar

- **200**: Code issued
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)
- **429**: rate_limited

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/auth/device/code' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"client_name": "gyro-cli", "client_version": "1.31.0", "hostname": "laptop", "os": "linux/amd64", "template": "readonly", "scopes": ["cloud_read", "services_read"], "lang": "tr"}'
```
```bash
gyro api request POST /auth/device/code --data '{"client_name": "gyro-cli", "client_version": "1.31.0", "hostname": "laptop", "os": "linux/amd64", "template": "readonly", "scopes": ["cloud_read", "services_read"], "lang": "tr"}'
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/auth/device/code", headers=h, json={"client_name": "gyro-cli", "client_version": "1.31.0", "hostname": "laptop", "os": "linux/amd64", "template": "readonly", "scopes": ["cloud_read", "services_read"], "lang": "tr"}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/auth/device/code", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"client_name": "gyro-cli", "client_version": "1.31.0", "hostname": "laptop", "os": "linux/amd64", "template": "readonly", "scopes": ["cloud_read", "services_read"], "lang": "tr"}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /auth/device/token

**Anahtarı sorgula (cihaz kodu)** · operationId `pollDeviceToken` · scope `` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/pollDeviceToken.json

API anahtarı gerekmez. Beklerken 400 hataları: `authorization_pending` (her `interval` saniyede sormaya devam), `slow_down` (details.interval yeni aralık), `access_denied` (tarayıcıda reddedildi ya da hesap artık anahtar alamıyor), `expired_token`, `invalid_grant` (bilinmeyen ya da kullanılmış kod). 200 bir kez: yeni anahtar (`access_token`).


### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `device_code` (zorunlu) | string |  |

### Yanıtlar

- **200**: Approved: the key, once
- **400**: authorization_pending | slow_down | access_denied | expired_token | invalid_grant
- **429**: rate_limited

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/auth/device/token' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"device_code": "string"}'
```
```bash
gyro api request POST /auth/device/token --data '{"device_code": "string"}'
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/auth/device/token", headers=h, json={"device_code": "string"}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/auth/device/token", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"device_code": "string"}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## GET /auth/session

**Kullanılan anahtar: hesap, izinler, bitiş** · operationId `getAuthSession` · scope `` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/getAuthSession.json

Geçerli her anahtar (kapsam gerekmez).


### Yanıtlar

- **200**: Session
- **401**: Missing, invalid or revoked key

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/auth/session' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro api request GET /auth/session
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/auth/session", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/auth/session", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /auth/session

**Kullanılan anahtarı iptal et (çıkış)** · operationId `deleteAuthSession` · scope `` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/deleteAuthSession.json

Bu isteği gönderen anahtarı iptal eder (geçerli her anahtar, kapsam gerekmez). API Kimlik Bilgileri sayfasında iptal edilmiş olarak görünür.


### Yanıtlar

- **200**: Revoked
- **401**: Missing, invalid or revoked key

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/auth/session' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro api request DELETE /auth/session
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/auth/session", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/auth/session", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```
