> For the complete documentation index, see [llms.txt](https://docs.geopard.tech/geopard-tutorials/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.geopard.tech/geopard-tutorials/ro/documentatie-api/authorization-apikey-credentials-or-oauth-2.0.md).

# Autorizare: ApiKey, acreditări sau OAuth 2.0

Soluția GeoPard utilizează [AWS Cognito](https://docs.aws.amazon.com/en_us/cognito/latest/developerguide/what-is-amazon-cognito.html) pentru procesul de autentificare.

Vă recomandăm să verificați toate opțiunile de autorizare. Alegerea depinde de cazul de utilizare specific. Mai jos sunt descrise detalii suplimentare despre fiecare opțiune.

## Opțiunea 1: Utilizarea acreditărilor

Autorizarea cu „nume de utilizator” și „parolă” este una dintre abordările posibile. În acest caz, este necesară înregistrarea prin e-mail (nu prin rețele sociale).

{% hint style="info" %}
Această abordare ***este recomandată pentru integrarea la nivelul API-ului (BackEnd)*** și toate solicitările către API-ul GeoPard sunt direcționate printr-un serviciu special dedicat (microserviciu).
{% endhint %}

### Solicitare de autentificare

{% 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 %}

### Răspuns la autentificare

{% hint style="danger" %}
Tokenul este un JWT cu o durată de valabilitate de 30 de minute.\
\
Este recomandat să stocați un singur token și să îl reutilizați pentru toate solicitările, verificându-i timpul de expirare și obținând un token nou atunci când expiră (sau cu puțin timp înainte).
{% endhint %}

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

## Opțiunea 2: OAuth 2.0

AWS Cognito acceptă protocolul OAuth 2.0 pentru autorizare. Prezentarea generală este descrisă în articolul [Ghidul OAuth2 pentru Cognito](https://aws.amazon.com/ru/blogs/mobile/understanding-amazon-cognito-user-pool-oauth-2-0-grants/), iar subarticolul „Authorization Code Grant” este cel mai relevant în cazul GeoPard.

{% hint style="info" %}
Această abordare ***este recomandată pentru integrarea GeoPard la nivelul interfeței utilizator (FrontEnd)***. Integrarea funcționează în ambele sensuri, pentru a trimite și a primi date de la și către GeoPard.
{% endhint %}

Pe scurt:

1. Aplicația dvs. trebuie să redirecționeze utilizatorul către GeoPard Cognito pentru autentificare sau înregistrare.

Exemplu:

{% 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 %}

Vă rugăm să contactați echipa GeoPard pentru a primi valoarea individuală `client_id`.

2. URL-ul de redirecționare va primi un cod de verificare `code` pentru pasul următor.

URL-ul de redirecționare arată astfel: [`http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a&state=54321`](http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a\&state=54321).

3. Aplicația dvs. trebuie să schimbe `code` în `tokens` (`access_token`, `refresh_token`, `id_token`).

Exemplu:

{% 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 %}

## Opțiunea 3: Cheie API

Accesul rapid la WMS și WFS este necesar din când în când. Prin urmare, se poate folosi cheia API GeoPard, generată automat pentru fiecare cont.

Cheia API poate fi găsită în `apiKey` atributul entității GraphQL „UserData”. Instrucțiuni despre cum să o obțineți `apiKey` sunt disponibile [AICI](https://docs.geopard.tech/geopard-tutorials/ro/documentatie-api/geopard-api-requests-overview/38.-query-get-userdata.md).

{% hint style="danger" %}
`apiKey` trebuie folosită numai cu `/geo` punctele finale.
{% endhint %}

Utilizare:

1. Ca `parametru geopardApiKey` în URL-ul solicitării GET.
2. Ca `antet X-API-Key` în ORICE solicitare.<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.geopard.tech/geopard-tutorials/ro/documentatie-api/authorization-apikey-credentials-or-oauth-2.0.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
