> 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/autorizare-apikey-acreditari-sau-oauth-2.0.md).

# Autorizare: ApiKey, acreditări sau OAuth 2.0

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

Recomandăm verificarea tuturor opțiunilor de autorizare. Alegerea depinde de cazul de utilizare particular. Mai multe detalii de utilizare sunt descrise pentru fiecare opțiune mai jos.

## Opțiunea 1: Utilizarea credențialelor

Autorizarea cu „username” și „password” este una dintre abordările posibile. În acest caz, înregistrarea prin email trebuie realizată (fără utilizarea rețelelor sociale).&#x20;

{% hint style="info" %}
Abordarea ***este recomandată pentru integrarea la nivel de API (BackEnd)*** și toate cererile către API-ul GeoPard sunt proxiate printr-un serviciu dedicat special (microserviciu).
{% endhint %}

### Cerere de autentificare&#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 %}

### Răspuns la autentificare

{% hint style="danger" %}
Tokenul este un JWT cu o durată de viață de 30 de minute.\
\
Este cea mai bună practică să stocați un singur token și să-l reutilizați pentru toate cererile, verificând timpul său de expirare și obținând un token nou când expiră (sau puțin înainte).
{% endhint %}

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

## Opțiunea 2: OAuth 2.0

AWS Cognito suportă protocolul OAuth 2.0 pentru autorizare. Prezentarea generală este descrisă în articolul [Manual Cognito OAuth2](https://aws.amazon.com/ru/blogs/mobile/understanding-amazon-cognito-user-pool-oauth-2-0-grants/), sub-articolul Authorization Code Grant este cel mai interesant în cazul GeoPard.&#x20;

{% hint style="info" %}
Abordarea ***se recomandă integrarea GeoPard la nivelul Interfeței Utilizator (FrontEnd)***. Integrarea funcționează în ambele direcții pentru a trimite/primi date către/de la GeoPard.
{% endhint %}

Pe scurt:

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

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ă vă conectați cu echipa GeoPard pentru a primi aplicației dvs. un `client_id`.

2. URL-ul redirecționat va primi un `cod` pentru pasul următor.

URL-ul redirecționat 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 `cod` pentru `tokenuri` (`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, este posibil să folosiți cheia API GeoPard generată automat pentru fiecare cont.

Cheia API poate fi găsită în `cheieApi` atributul entității GraphQL "UserData". Instrucțiuni despre cum să recuperați  `cheieApi` sunt furnizate [AICI](/geopard-tutorials/ro/documentatie-api/prezentare-generala-a-cererilor-api-geopard/38.-interogare-obtine-dateutilizator.md).

{% hint style="danger" %}
`cheieApi` trebuie folosită cu `/geo` endpoint-uri DOAR.
{% endhint %}

Utilizare:

1. Ca un `geopardApiKey` parametru în URL-ul cererii GET.
2. Ca un `X-API-Key` header în ORICE cerere.<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/autorizare-apikey-acreditari-sau-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.
