# Yetkilendirme: ApiKey, Credentials veya OAuth 2.0

GeoPard çözümü şu şekilde kullanıyor [AWS Cognito](https://docs.aws.amazon.com/en_us/cognito/latest/developerguide/what-is-amazon-cognito.html) yetkilendirme prosedürü için.

Tüm yetkilendirme seçeneklerini kontrol etmenizi öneririz. Seçim belirli kullanım durumuna bağlıdır. Daha fazla kullanım detayı aşağıdaki her bir seçenekte açıklanmıştır.

## Seçenek 1: Kimlik Bilgileri Kullanımı

“kullanıcı adı” ve “parola” ile yetkilendirme olası yaklaşımlardan biridir. Bu durumda e-posta ile kayıt yapılmalıdır (sosyal ağlar kullanılmaz).&#x20;

{% hint style="info" %}
Bu yaklaşım ***API (Arka Uç) seviyesinde entegrasyon için önerilir*** ve GeoPard API'ye yapılan tüm istekler özel bir servis (mikroservis) aracılığıyla proxylenir.
{% endhint %}

### Giriş İsteği&#x20;

{% code overflow="wrap" lineNumbers="true" %}

```bash
curl --location --request POST 'https://api.geopard.tech/login' \
--header 'Content-Type: application/json' \
--header 'Content-Type: text/plain' \
--data-raw '{"username":"<email_address>","password":"<password>"}'
```

{% endcode %}

### Giriş Yanıtı

{% hint style="danger" %}
Token, 30 dakikalık ömre sahip bir JWT'dir.\
\
En iyi uygulama tek bir token saklayıp tüm isteklerde onu yeniden kullanmak, süresinin dolup dolmadığını kontrol etmek ve süresi dolduğunda (veya kısa bir süre öncesinde) yeni bir token almaktır.
{% endhint %}

```json
{
    "token": "<token_to_use_in_geopard_api>"
}
```

## Seçenek 2: OAuth 2.0

AWS Cognito yetkilendirme için OAuth 2.0 protokolünü destekler. Genel bakış makalede açıklanmıştır [Cognito OAuth2 kılavuzu](https://aws.amazon.com/ru/blogs/mobile/understanding-amazon-cognito-user-pool-oauth-2-0-grants/), GeoPard vakasında en ilginç olanı Authorization Code Grant alt-makalasıdır.&#x20;

{% hint style="info" %}
Bu yaklaşım ***GeoPard'ın Kullanıcı Arayüzü (Ön Uç) seviyesinde entegre edilmesi önerilir***. Entegrasyon, GeoPard ile veri gönderme/alma yönlerinde her iki yönde çalışır.
{% endhint %}

Kısaca özetlemek gerekirse:

1. Uygulamanız kullanıcının giriş veya kayıt işlemi için kullanıcıyı GeoPard Cognito'ya yönlendirmelidir.&#x20;

Örnek:

{% code overflow="wrap" lineNumbers="true" %}

```bash
curl --location --request GET '
https://auth.geopard.tech/oauth2/authorize?response_type=code&client_id=<connect_geopard_team>&redirect_uri=http://localhost:8080&state=54321
'
```

{% endcode %}

Uygulamanız için bireysel almak üzere lütfen GeoPard ekibiyle bağlantı kurun `client_id`.

2. Yönlendirilen URL bir doğrulama alacaktır `kod` bir sonraki adım için.

Yönlendirilen URL şu şekilde görünür [`http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a&state=54321`](http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a\&state=54321).

3. Uygulamanız şunu değiş tokuş etmelidir `kod` için `tokenler` (`access_token`, `refresh_token`, `id_token`).

Örnek:

{% code overflow="wrap" lineNumbers="true" %}

```bash
curl --location --request POST '
https://auth.geopard.tech/oauth2/token
' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: XSRF-TOKEN=365e14e1-3c66-477e-b0ef-a9e436a834ee; csrf-state=""; csrf-state-legacy=""' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a' \
--data-urlencode 'client_id=42ajne9u466in6gaf569nth9o9' \
--data-urlencode 'redirect_uri=
http://localhost:8080
'
```

{% endcode %}

## Seçenek 3: API Anahtarı

WMS ve WFS'ye hızlı erişim zaman zaman gerekli olabilir. Bu nedenle, her hesap için otomatik olarak oluşturulan GeoPard API anahtarını kullanmak mümkündür.

API anahtarı `apiAnahtarı` "UserData" GraphQL varlığının  `apiAnahtarı` özniteliğinde bulunabilir. Nasıl alınacağına dair talimatlar [BURADA](/geopard-tutorials/tr/api-belgeleri/geopard-api-isteklerine-genel-bakis/38.-sorgu-userdata-getir.md).

{% hint style="danger" %}
`apiAnahtarı` ile kullanılmalıdır `/geo` uç noktaları SADECE ile.
{% endhint %}

Kullanım:

1. Bir `geopardApiKey` GET isteği URL'sindeki parametre olarak.
2. Bir `X-API-Key` herhangi bir istekte başlık olarak.<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.geopard.tech/geopard-tutorials/tr/api-belgeleri/yetkilendirme-apikey-credentials-veya-oauth-2.0.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
