> 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/jpn/apidokyumento/authorization-apikey-credentials-or-oauth-2.0.md).

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

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

すべての認証オプションを確認することをおすすめします。最適な選択肢は、具体的なユースケースによって異なります。各オプションの使用方法の詳細は、以下で説明します。

## オプション 1: 認証情報を使用する

「ユーザー名」と「パスワード」による認証は、利用可能な方法の1つです。この場合、メールアドレスで登録する必要があります（ソーシャルネットワーク経由での登録は使用しません）。

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

### ログインリクエスト

{% 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です。\
\
ベストプラクティスは、トークンを1つだけ保存し、すべてのリクエストで再利用することです。有効期限を確認し、期限切れ時（または期限切れの少し前）に新しいトークンを取得してください。
{% 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/)。GeoPardの場合、サブ記事の「認証コードグラント」が最も参考になります。

{% hint style="info" %}
この方法は、 ***ユーザーインターフェース（フロントエンド）レベルでGeoPardを統合する場合に推奨されます***。この統合では、GeoPardとの間で双方向にデータを送受信できます。
{% endhint %}

要点を簡潔にまとめると、

1. アプリケーションからユーザーをGeoPard Cognitoにリダイレクトし、ログインまたは登録させる必要があります。

例:

{% 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`](http://localhost:8080/?code=eb10956a-6d51-49e5-bbfe-9815e3fdc70a\&state=54321).

3. アプリケーションでは、 `code` を `tokens` (`access_token`, `refresh_token`, `id_token`).

例:

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

## オプション 3: APIキー

WMSやWFSにすばやくアクセスする必要が生じることがあります。そのため、すべてのアカウントで自動生成されるGeoPard APIキーを使用できます。

APIキーは、 `apiKey` GraphQLエンティティ「UserData」の属性にあります。取得方法の説明は `apiKey` こちらに [記載されています](https://docs.geopard.tech/geopard-tutorials/jpn/apidokyumento/geopard-api-requests-overview/38.-query-get-userdata.md).

{% hint style="danger" %}
`apiKey` は、 `/geo` エンドポイントでのみ使用してください。
{% endhint %}

使用方法：

1. GETリクエストのURLで、パラメーター `geopardApiKey` として指定します。
2. 任意のリクエストのヘッダー `X-API-Key` として指定します。<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/jpn/apidokyumento/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.
