> 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/de/api-dokumentation/autorisierung-apikey-zugangsdaten-oder-oauth-2.0.md).

# Autorisierung: ApiKey, Zugangsdaten oder OAuth 2.0

Die GeoPard-Lösung verwendet [AWS Cognito](https://docs.aws.amazon.com/en_us/cognito/latest/developerguide/what-is-amazon-cognito.html) für das Authentifizierungsverfahren.

Wir empfehlen, alle Autorisierungsoptionen zu prüfen. Die Wahl hängt vom jeweiligen Anwendungsfall ab. Weitere Nutzungsdetails sind in den einzelnen Optionen unten beschrieben.

## Option 1: Verwendung von Zugangsdaten

Die Autorisierung mit „Benutzername“ und „Passwort“ ist eine der möglichen Vorgehensweisen. In diesem Fall muss eine E-Mail-Registrierung erfolgen (nicht über soziale Netzwerke).&#x20;

{% hint style="info" %}
Der Ansatz ***wird für die Integration auf API-(BackEnd-)Ebene empfohlen*** und alle Anfragen an die GeoPard-API werden über einen dedizierten speziellen Dienst (Microservice) proxied.
{% endhint %}

### Login-Anfrage&#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 %}

### Login-Antwort

{% hint style="danger" %}
Das Token ist ein JWT mit einer Lebensdauer von 30 Minuten.\
\
Es ist Best Practice, ein einzelnes Token zu speichern und es für alle Anfragen wiederzuverwenden, dessen Ablaufzeit zu prüfen und ein neues Token abzurufen, wenn es abläuft (oder kurz davor).
{% endhint %}

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

## Option 2: OAuth 2.0

AWS Cognito unterstützt das OAuth-2.0-Protokoll für die Autorisierung. Die allgemeine Übersicht ist im Artikel beschrieben [Cognito OAuth2 Handbuch](https://aws.amazon.com/ru/blogs/mobile/understanding-amazon-cognito-user-pool-oauth-2-0-grants/), der Unterartikel Authorization Code Grant ist im GeoPard-Fall am relevantesten.&#x20;

{% hint style="info" %}
Der Ansatz ***wird empfohlen, GeoPard auf der Benutzeroberflächen-(FrontEnd-)Ebene zu integrieren***. Die Integration funktioniert in beide Richtungen, um Daten an GeoPard zu senden/von GeoPard zu empfangen.
{% endhint %}

Kurz gesagt:

1. Ihre Anwendung muss einen Benutzer zur Anmeldung oder Registrierung an GeoPard Cognito weiterleiten.&#x20;

Beispiel:

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

Bitte kontaktieren Sie das GeoPard-Team, um Ihre individuelle Anwendung `client_id`.

2. Die weitergeleitete URL erhält einen Verifizierungs- `Code` für den nächsten Schritt.

Die weitergeleitete URL sieht aus wie [`http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a&state=54321`](http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a\&state=54321).

3. Ihre Anwendung muss `Code` für `Token` (`access_token`, `refresh_token`, `id_token`).

Beispiel:

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

## Option 3: API-Schlüssel

Für den schnellen Zugriff auf WMS und WFS ist dies von Zeit zu Zeit erforderlich. Daher ist es möglich, den automatisch für jedes Konto generierten GeoPard-API-Schlüssel zu verwenden.

Der API-Schlüssel ist im `API-Schlüssel` Attribut der "UserData"-GraphQL-Entität zu finden. Anweisungen zum Abruf  `API-Schlüssel` werden bereitgestellt [HIER](/geopard-tutorials/de/api-dokumentation/uberblick-uber-geopard-api-anfragen/38.-abfrage-userdata-abrufen.md).

{% hint style="danger" %}
`API-Schlüssel` muss mit `/geo` Endpunkten NUR verwendet werden.
{% endhint %}

Verwendung:

1. Als `geopardApiKey` Parameter in der GET-Anfrage-URL.
2. Als ein `X-API-Key` Header in JEDER Anfrage.<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 dynamically by asking a question.

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

```
GET https://docs.geopard.tech/geopard-tutorials/de/api-dokumentation/autorisierung-apikey-zugangsdaten-oder-oauth-2.0.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
