> ## 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.

> ## Agent Instructions
> ### Authlete versions
> Authlete 3.0 is the current version. Unless the user says they use another version, answer for Authlete 3.0 using the 3.x documentation.
> Documentation for Authlete 2.x (pages under `/v2/` and `/ja/v2/`) is for the legacy version. Refer to it only when the user is on Authlete 2.x.
>
> ### Authlete architecture
> Authlete is a backend engine for OAuth 2.0 and OpenID Connect processing. End users and client applications do not call it directly; the service provider's authorization server and API server call Authlete's APIs. Authlete handles protocol processing and token, client, and service management, while the service provider owns the OAuth/OIDC endpoints and user authentication.
> See [Architecture](https://developers.authlete.com/get-started/introduction-to-authlete/architecture.md).
>
> ### Concepts
> If the user is new to Authlete, read these pages first:
> - [Request and Response](https://developers.authlete.com/get-started/concepts/request-and-response.md): Core API requests pass the client's request parameters as-is, and responses return `resultCode`, `action`, and `responseContent`.
> - [Action Handling](https://developers.authlete.com/get-started/concepts/action-handling.md): Branch on `action`, never on `resultCode`, and map each action to the HTTP response your server returns.
> - [Two-Step API Calls](https://developers.authlete.com/get-started/concepts/two-step-api-calls.md): Actions such as `INTERACTION` are completed with a second call (`/auth/authorization/issue` or `/auth/authorization/fail`) linked by a `ticket`.
> - [Management API Overview](https://developers.authlete.com/get-started/concepts/overview.md): The Management API configures services, manages clients, and operates issued tokens, separately from the protocol flows handled by the Core API.
> - [API Authentication](https://developers.authlete.com/get-started/concepts/authentication.md): Authlete APIs use bearer tokens: a Service Access Token (one service) or an Organization Token (the whole organization).

# クイックスタート

> Authlete 2.x（api.authlete.com）を用いて OAuth 2.0 認可フローを試すためのクイックガイドです。

> [!NOTE]
>
> このページは **Authlete 2.x** 用です。3.0 については [クイックスタート（3.0）](https://developers.authlete.com/ja/get-started/setting-up-authlete) をご覧ください。

# Authlete を用いて「OAuth 2.0 認可フロー」を試す（2.x）

## 1. アカウントを作成しましょう。

[サインアップページ](https://so.authlete.com/accounts/signup) に必要事項を入力し「登録」をクリックします。

![1. アカウントを作成](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_01_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=60929747dd650a3397ae5e0426d33126)

## 2. メールを開きます。

登録完了後に届くメールに、認可フローを試すための手順が書いてあります。

![2. メールを開く](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_03_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=ec659a80d924d20d0dd711ea62e4bfcb)

> [!NOTE]
>
> **💡** 登録完了後、すぐに OAuth 2.0 のフローを試せるよう、以下の設定がすでに完了しています。
>
> * **Authlete サービスインスタンス**
> * **デフォルトの OAuth 2.0 認可エンドポイント**
> * **クライアントアプリのサンプル設定**

## 3. 「認可エンドポイント」ボタンをクリックします。

認証・認可を行うためのログインページに遷移します。

![3. 認可エンドポイント](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_14_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=ffdfe9ccd34069c357fcc288dad6ca55)

> [!NOTE]
>
> **💡** 「認可エンドポイント」ボタンをクリックすると、Authlete のデフォルト認可エンドポイントに認可リクエスト（インプリシットグラントフロー）を行います。実際には以下の URL です。
> `https://api.authlete.com/api/auth/authorization/direct/<SERVICE_API_KEY>?response_type=token&client_id=<SAMPLE_APP_CLIENT_ID>`

## 4. ログイン情報を入力します

Authlete サービスインスタンスの API キーと API シークレットを用います。

![4. ログイン情報入力](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_21_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=bf87f591d73d5fb9e62ac39a0a166a77)

**注:** API キーと API シークレットはサービス管理者コンソールにログインして確認します。

1. **メール内のボタンをクリック**

![メール内のボタン](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_24_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=bf97ed1d41234efa49f7996030c6c127)

2. **API キーとシークレットを確認**

![API キーとシークレット](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_25_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=26f313ca3677263403dbecae29525f6c)

> [!NOTE]
>
> **💡** 動作確認用に、デフォルト認可エンドポイントは API キーと API シークレットを用いてユーザーを認証します。

## 5. 「認可」ボタンをクリックします

ブラウザはクライアントのリダイレクションエンドポイントに遷移します。発行されたアクセストークンが表示されます。

また、遷移後の URL のフラグメント部にアクセストークンが含まれています。

`https://api.authlete.com/api/mock/redirection/<SERVICE_API_KEY>#access_token=SNqzo...&token_type=Bearer&expires_in=86400&scope=`

![5. 認可完了・アクセストークン](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_22_en.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=e706b71f52237c88fcf63955ef19f633)

> [!NOTE]
>
> **おめでとうございます!** Authlete を使ったアクセストークンの発行ができました!

***

## 認可コードグラントフローを試す

上記（インプリシットグラントフロー）に続き、認可コードグラントフローを試してみましょう。

**1.** Web ブラウザーに以下の URL（認可リクエスト）を入力・送信してください。

`https://api.authlete.com/api/auth/authorization/direct/<SERVICE_API_KEY>?response_type=code&client_id=<SAMPLE_APP_CLIENT_ID>`

`response_type=code` である以外は先の認可リクエストと同一です。`<SERVICE_API_KEY>` / `<SAMPLE_APP_CLIENT_ID>` は適宜修正してください。

**2.** さきほどと同じログインページに遷移します。API キーと API シークレットを入力してください。

![認可コードフロー・ログイン](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_31_ja.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=bc1dfb377432ecfdc17fc2b900433a52)

**3.** トークンリクエスト送信ページに遷移します。`client_id` フィールドに `SAMPLE_APP_CLIENT_ID` の値を入力し、Submit ボタンをクリックしてください。

![トークンリクエスト送信](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_32_en.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=add43fa3a1e346181c0fedbb1adaaccb)

**4.** トークンレスポンス（JSON 形式）の内容が表示されます。`"access_token"` と `"refresh_token"` のそれぞれに値が入っていることを確認してください。

![トークンレスポンス](https://mintcdn.com/authlete/Z6xXwx0zbVgSByug/img/developers/getting_started/getting_started_33_en.png?fit=max\&auto=format\&n=Z6xXwx0zbVgSByug\&q=85\&s=b141bd130c107989f391c8da572b7674)

***

## 認可サーバーを実装する

ここまでのセクションでは、Authlete のデフォルトの認可エンドポイント実装を用いて認可フローを試しました。実環境での Authlete の活用にあたっては、さまざまな方法で、Authlete の Web API を使った認可サーバーを実装することが可能です。

**java-oauth-server** はオープンソースの認可サーバーであり、Authlete の Web API を使って実装されています。この、Java を使った参照実装は、独自の認可サーバーを構築する際の参考となるものです。同参照実装は Authlete をバックエンドとして用いています。

その結果、下記のいくつかのコマンドだけで、認可サーバー（java-oauth-server）のダウンロードから実行までが完了します。

```bash theme={null}
$ git clone https://github.com/authlete/java-oauth-server.git
$ cd java-oauth-server
$ vi authlete.properties
```

(Authlete サービスインスタンスの API キーとシークレットを記述)

```bash theme={null}
$ mvn jetty:run
```

その他の参照実装（Java (Spring), C#, PHP (Laravel)）の詳細は [Authlete ウェブサイト クイックスタート（2.x）](https://www.authlete.com/ja/developers/v2/getting_started/) をご参照ください。

***

## 次のステップ

* **[Authlete のセットアップ（2.x）](https://developers.authlete.com/ja/v2/get-started/setting-up-authlete.md)**: サービス・クライアント管理の概要
* **[JavaでのAuthlete API入門（2.x）](https://developers.authlete.com/ja/v2/get-started/quickstarts/getting-started-with-the-authlete-apis-in-java.md)**: java-oauth-server を動かしてフローをテストする手順
* [API リファレンス](https://developers.authlete.com/api-reference) — Authlete 2.x Web API


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.