> ## Documentation Index
> Fetch the complete documentation index at: https://developers.authlete.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API を使ってみる 🚀

> Authlete アカウントの設定から API 呼び出しまで、数分で試してみましょう。

<Note>
  このページは Authlete 3.0 用です。2.x の場合は [クイックスタート(2.x)](/ja/v2/get-started/quickstarts/getting-started) をご覧ください。
</Note>

<h2 id="1-create-an-authlete-account">1. Authlete アカウントを作成する</h2>

Authlete を使用するにはアカウントが必要です。登録後、管理コンソールを通じてすべての機能を設定できます。

[Authlete の Web サイトにアクセス](https://www.authlete.com/ja/home)し、右上の [Free Trial (無料トライアル)](https://console.authlete.com/register) をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/1.png" alt="右上に無料トライアルボタンが表示されたAuthleteウェブサイトホームページ" />
</Frame>

お好みの登録方法を選択します。**ソーシャルログイン (Google またはGitHub)** または**メールアドレス**でサインアップできます。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/2.png" alt="登録オプションを表示するサインアップページ: GoogleおよびGitHubソーシャルログインボタン、およびメールアドレスサインアップフィールド" />
</Frame>

ソーシャルログインまたはメールアドレスの確認後、**First Name**、**Last Name**、**Organization Name** の入力と（メールアドレス登録の場合には **Password** も）、プライバシーポリシーと利用規約の確認を行い、**Register** をクリックしてサインアップを完了します。

<Frame className="mx-auto" style={{ maxWidth: '25%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/6.png" alt="名、姓、組織名の入力フィールドを備えたユーザープロフィールフォーム、プライバシーポリシーと利用規約を確認するチェックボックス、および青い登録ボタン" />
</Frame>

***

<h2 id="2-create-a-service">2. サービスを作成する</h2>

サインアップ直後、**Services** ページにリダイレクトされます。このページには **Organization** (サインアップ時に作成) のすべての Service が表示されます。

**Service** はあなたの認可サーバーのバックエンドです。Service には、認可サーバーを本番運用するために必要なすべての設定 (OAuth/OIDC 設定、トークン管理、セキュリティポリシーなど) が含まれます。

新しい Service を Organization に追加するには、**Create Service** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/104.png" alt="組織の既存サービスのリストを表示するサービスページと、右上の青いサービス作成ボタン" />
</Frame>

1. お好みの **API Cluster** の場所 (例: `US`) を選択します。Service のすべてのデータが、ここで選択した Cluster に保存されます。データレジデンシーと環境分離の要件に基づいて Cluster を選択してください。
2. **Service Name** (例: `Sample Service`) を入力します。
3. **Create** をクリックして、セットアップを完了します。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/105.png" alt="APIクラスタ位置を選択するドロップダウンメニュー、サービス名の入力フィールド、および青い作成ボタンを表示する作成サービスフォーム" />
</Frame>

これで新しい Service の作成が完了しました。

***

<h2 id="3-create-a-service-access-token">3. サービスアクセストークンを作成する</h2>

Authlete API を呼び出すには、**Service Access Token** による認証が必要です。

新しく作成した Service の **Service Settings** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/106.png" alt="新しく作成されたサービスのサービス設定オプションが表示されているサービス概要ページ" />
</Frame>

1. **Service Identifier** の値 (例: `3615784225`) をメモします (Authlete API の多くが、リクエスト時にこの値を必要とします)。
2. **Create Token** をクリックして、新しい Service Access Token を作成します。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/107.png" alt="サービス識別子の値を表示し、新しいサービスアクセストークンを生成する青いトークン作成ボタンを表示するサービス設定ページ" />
</Frame>

1. **Token Name** (例: `oauth-server-token`) を入力します。
2. **Expiration Date** を指定します。
3. 適切な **Permission** (例: **Authorization Server** プリセット) を選択します。
4. **Create Token** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/108.png" alt="oauth-server-tokenのトークン名フィールド、日付ピッカーの有効期限フィールド、オレンジでハイライトされた認可サーバーオプションの権限プリセットセクション、下部の青いトークン作成ボタンを表示するサービスアクセストークン追加ダイアログ" />
</Frame>

新しい Service Access Token がリストに表示されます。

1. **Copy** または **Show** をクリックしてトークン値を取得します。この値を、以降の API リクエスト時の認証に用います。また、この値は作成時のみ表示されることにご注意ください。
2. **Back to Service Overview** をクリックして、Service のメインページに戻ります。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/109.png" alt="新しく作成されたトークンの横にコピーボタンと表示ボタンが表示されているサービスアクセストークンリストと、メインサービスページに戻るサービス概要へのバックリンク" />
</Frame>

*これでAuthlete APIをテストする準備ができました!*

***

<h2 id="4-call-the-authlete-api">4. Authlete API を呼び出す</h2>

最初の API リクエストを、[/service/configuration](/api-reference/service-management/get-service-configuration) API に送信してみましょう。この API は OIDC ディスカバリーエンドポイントのバックエンドとして機能し、同エンドポイントがクライアント (OIDC リライングパーティー) からのリクエストに応じて返却する OpenID プロバイダーメタデータを生成します。

```mermaid placement="top-right" theme={null}

%%{init: {
  'themeVariables': {
    'fontSize': '20px',
    'nodeTextMargin': 40
  },
  'flowchart': {
    'nodeSpacing': 40,
    'rankSpacing': 40,
    'padding': 5
  }
}}%%

graph LR

client[OIDC RP]

subgraph as[OIDC IdP]
    direction TB
    disco[Discovery<br/>Endpoint]
end

subgraph authlete[Authlete]
    direction TB
    config["/service/configuration<br/>API"]
end

client -- Metadata<br/>Request --> disco
disco -- Service<br/>Configuration<br/>Request<br/> --> config
```

以下は **curl** と **API エクスプローラー** を用いる例です。プレースホルダーを実環境の値に置き換えてください。

| 項目                       | 値                                             |
| :----------------------- | :-------------------------------------------- |
| **API Cluster のホスト名**    | `https://us.authlete.com`                     |
| **Service Access Token** | `qwEF2t8gxW9MerraRyVtscDTKVPa66kjBBPUpBduvXw` |
| **Service ID**           | `3615784225`                                  |

<h3 id="using-curl">curl を使用する</h3>

ターミナルで以下のコマンドを実行して、HTTP GET リクエストを送信します:

<CodeGroup>
  ```bash For Linux/MacOS theme={null}
  curl -X GET "https://us.authlete.com/api/3615784225/service/configuration" \
   -H "Authorization: Bearer qwEF2t8gxW9MerraRyVtscDTKVPa66kjBBPUpBduvXw"
  ```

  ```powershell For Windows theme={null}
  curl.exe -X GET "https://us.authlete.com/api/3615784225/service/configuration" `
   -H "Authorization: Bearer qwEF2t8gxW9MerraRyVtscDTKVPa66kjBBPUpBduvXw" | ConvertFrom-Json
  ```
</CodeGroup>

成功した場合、API は以下のような OpenID プロバイダーメタデータを返します:

```json theme={null}
{
  "issuer": "https://authlete.com",
    [...]
  "scopes_supported": [
    "address",
    "email",
    "openid",
    "offline_access",
    "phone",
    "profile",
    "grant_management_query",
    "grant_management_revoke"
  ],
  "response_types_supported": [
    "none",
    "code",
    "id_token",
    "code id_token"
  ],
[...]
}
```

<h3 id="using-api-explorer">API エクスプローラーを使用する</h3>

[/service/configuration API リファレンスページ](/api-reference/service-management/get-service-configuration)を開き、**Try it** ボタンをクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/110.png" alt="/service/configurationエンドポイントのAPIエクスプローラーインターフェース、クリックしてAPIをテストする準備ができた試してみるボタン" />
</Frame>

1. **API Cluster のホスト名**を選択します。
2. **Service Access Token** を入力します。
3. **Service ID** を入力します。
4. **Send** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/111.png" alt="サービスIDとサービスアクセストークンの入力フィールド、およびAPIリクエストを実行する青い送信ボタンを表示するAPIエクスプローラーフォーム" />
</Frame>

API レスポンスはレスポンスセクションに表示されます。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/112.png" alt="APIエクスプローラーのレスポンスセクションに表示されたAPIレスポンス。発行者、サポートされているスコープ、応答タイプを含むサービス構成の詳細を含むJSONデータを表示" />
</Frame>

***

<h2 id="next-steps">次のステップ</h2>

これで Authlete アカウントのセットアップとサービス設定が完了しました。さらに詳しく探索してみましょう。

* [**OAuth 2.0 Basics - API Tutorials**](/ja/get-started/quickstarts/oauth-2-0-basics): curl や他のツールを使用して API を直接呼び出して、Authlete がどのように機能するかを学びます。
* [**Using Demo Authorization Server**](/ja/get-started/quickstarts/using-demo-authorization-server): Authlete API を用いて実装された、オープンソースの認可サーバーフロントエンドをデプロイして、実際の OAuth/OIDC フローをテストします。

***

<h2 id="extra-oauth%2Foidc-processing">Extra: OAuth/OIDC フローの処理</h2>

Authlete API による、OAuth/OIDC フローの処理を、認可リクエストのサンプルをもとに確認してみましょう。

<h3 id="create-a-client">クライアントを作成する</h3>

**Client** は、認可サーバーに対してトークン発行をリクエストしたり、リソースサーバーの保護されたリソースにアクセスするアプリケーションを表しています。Client は特定の Service のコンテキスト内で管理されます。

Services ページで、画面の右上にある **Create Client** ボタンをクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/113.png" alt="クリック準備ができた画面の右上に配置されたクライアント作成ボタンを備えたサービスページ" />
</Frame>

**Client Name** を入力して、**Create** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/114.png" alt="クライアント名の入力フィールドと新しいクライアントを追加する青い作成ボタンを備えたクライアント作成ダイアログフォーム" />
</Frame>

Client の詳細が表示されます。必要に応じて **Client ID** と **Client Secret** をメモします。アプリケーションのリダイレクト URI を登録するために、**Redirect URIs** セクションの **Add** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/115.png" alt="クライアントIDとクライアントシークレットの値を表示するクライアント詳細ページ、リダイレクトURIセクション、およびアプリケーションリダイレクトURIを登録する追加ボタン" />
</Frame>

例として、`https://client.example.org/cb/example.com` を入力して **Save Changes** をクリックします。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/116.png" alt="例の値 https://client.example.org/cb/example.com のリダイレクトURIの入力フォーム、およびエントリを確認する青い変更を保存ボタン" />
</Frame>

<h3 id="call-“process-authorization-request”-api">「認可リクエスト処理」API を呼び出す</h3>

[Try /auth/authorization API](/api-reference/authorization-endpoint/process-authorization-request?playground=open) ツールに移動します。

1. **API Cluster のホスト名**を選択します。
2. **Service Access Token** を入力します。
3. **Service ID** を入力します。
4. 以下の文字列 (認可リクエストの内容) を **parameters** フィールドに入力します。なお、
   `client_id` の値 (`2329821874`) は、前の手順で作成した実際の値に変更してください。
5. **Send** をクリックします。

| パラメーター         | 値                                                                                                |
| :------------- | ------------------------------------------------------------------------------------------------ |
| **parameters** | `redirect_uri=https://client.example.org/cb/example.com&client_id=2329821874&response_type=code` |

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/119.png" alt="API Explorer showing the /auth/authorization endpoint with parameters entered" />
</Frame>

API レスポンスがレスポンスセクションに表示されます。

<Frame className="mx-auto" style={{ maxWidth: '75%' }}>
  <img src="https://storage.googleapis.com/authlete-website/resources/tutorial-getting-started-images/120.png" alt="パラメータが入力され、レスポンスセクションに表示された/auth/authorizationエンドポイントのAPIエクスプローラー。認可リクエストの結果を表示するJSONレスポンス" />
</Frame>
