# 認証: ApiKey、Credentials、またはOAuth 2.0

GeoPardソリューションは次を使用しています [AWS Cognito](https://docs.aws.amazon.com/en_us/cognito/latest/developerguide/what-is-amazon-cognito.html) 認証手順のために。

すべての認可オプションを確認することを推奨します。選択は特定のユースケースによります。各オプションの詳細な利用方法は以下に記載されています。

## オプション1: 資格情報の使用

「ユーザー名」と「パスワード」による認証は可能なアプローチの一つです。この場合、（ソーシャルネットワークを使わずに）メールでの登録が必要です。&#x20;

{% hint style="info" %}
このアプローチは ***API（バックエンド）レベルでの統合に推奨されます*** および GeoPard API へのすべてのリクエストは専用の特別なサービス（マイクロサービス）を介してプロキシされます。
{% endhint %}

### ログインリクエスト&#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 %}

### ログインレスポンス

{% hint style="danger" %}
トークンは有効期間30分のJWTです。\
\
単一のトークンを保存してすべてのリクエストで再利用し、有効期限を確認して期限切れ（または期限直前）に新しいトークンを取得するのがベストプラクティスです。
{% endhint %}

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

## オプション2: OAuth 2.0

AWS Cognitoは認可のためのOAuth 2.0プロトコルをサポートしています。一般的な概要は記事に説明されています [Cognito OAuth2 マニュアル](https://aws.amazon.com/ru/blogs/mobile/understanding-amazon-cognito-user-pool-oauth-2-0-grants/), サブ記事の Authorization Code Grant が GeoPard の場合で最も興味深い項目です。&#x20;

{% hint style="info" %}
このアプローチは ***GeoPard をユーザーインターフェース（フロントエンド）レベルで統合することが推奨されます***&#x7D71;合は GeoPard への/からのデータ送受信の両方向で機能します。
{% endhint %}

要点を簡潔に：

1. あなたのアプリケーションはユーザーをログインまたは登録のために GeoPard Cognito にリダイレクトする必要があります。&#x20;

例：

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

アプリケーション固有の `client_id`.

2. を受け取るために GeoPard チームに接続してください `リダイレクトされたURLは次の検証用` code

を受け取ります。次のステップのために。 [`リダイレクトされたURLは次のようになります`](http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a\&state=54321).

3. <http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a\\&state=54321> `リダイレクトされたURLは次の検証用` のための `あなたのアプリケーションは下記を交換する必要があります` (`tokens`, `access_token`, `refresh_token`).

例：

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

```bash
id_token
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=
'
```

{% endcode %}

## <http://localhost:8080>

オプション3: APIキー

WMS と WFS への迅速なアクセスが時折必要です。したがって、各アカウント用に自動生成される GeoPard API キーを使用することが可能です。 `APIキー` API キーは "UserData" GraphQL エンティティの  `APIキー` 属性で見つけることができます。取得方法に関する手順は [ここ](/geopard-tutorials/jpn/apidokyumento/geopard-apirikuesuto/38-kueri-userdatawo.md).

{% hint style="danger" %}
`APIキー` で提供されています `は必ず` /geo
{% endhint %}

エンドポイントのみで使用してください。

1. 使用方法： `geopardApiKey` パラメーターとして GET リクエストの URL に。
2. ヘッダーとして `X-API-Key` 任意のリクエストのヘッダーに。<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/jpn/apidokyumento/apikeycredentialsmatahaoauth-20.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.
