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

# Personal Agent Protocol (Poppy)

> Personal Agent Protocol (Poppy) の概要、Poppy を実装する Company のために Authlete が担う部分、Authlete で保護された Company である Stays での動作確認の説明

## はじめに

[Personal Agent Protocol][POPPY_SITE] (略称『Poppy』) は、パーソナルエージェントと企業が連携する方法を定めたオープンなプロトコルです。利用者は自分の AI エージェントに部屋の予約、返品の開始、注文の確認などを頼むことができ、エージェントは利用者に代わって企業のもとでそれを実行します。エージェントに何をさせるかは企業が決め、自分のエージェントに何を任せるかは利用者が決めます。

Poppy は 2026 年 10 月に Sierra と Meta により発表され、2026 年 11 月に[バージョン 1.0][POPPY_CHANGELOG] がリリースされました。[Sierra のリリース記事][SIERRA_RELEASE]によると、すべての Shopify ストアが Poppy ファイルを公開しており、Meta の Muse エージェントは訪問するすべてのサイトでまず Poppy を探します。

Poppy の大部分は OAuth であり、Authlete は既にこれをサポートしています。Poppy は OAuth に加えて、Company を説明するディスカバリファイルと、すべてのリクエストに付与する署名付きの `Poppy-Session` ヘッダを定めています。このヘッダは自社の API が確認し、認可サーバーには届きません。そのため、Authlete の設定は CIMD を加えた OAuth のままです。このページでは各要素の関係を説明し、続いて、Authlete のリファレンス用 Poppy Company である **Stays** に対してフロー全体が動作する様子を紹介します。

### 用語

Poppy は、仕様で定義した用語を大文字で始めて表記します。次の定義は [Poppy 1.0 仕様][POPPY_SPEC]のセクション 2 に基づきます。

| 用語 | 意味 |
| - | - |
| User | Personal Agent が代理で動作する対象の人。 |
| Personal Agent | User のために動作するソフトウェア。 |
| Company | Personal Agent が連携できるようにプロトコルを実装する組織。 |
| Company Agent | サポートされた会話プロトコルを通じて利用する、Company 自身のエージェント。 |
| User ID | Personal Agent が、ある Company におけるある User に付与する ID。安定しており、仮名です。 |
| Session | 一人の User が、一つの Personal Agent を通じて、一つの Company で行う一連の活動。Web の閲覧、API、会話をまたぎます。 |
| Session ヘッダ | Personal Agent が送信するすべてのリクエストに付与する `Poppy-Session` ヘッダ。 |

## Poppy の仕組み

Company を初めて利用する Personal Agent は、次の手順を踏みます。例には、[Poppy の動作を見る](#poppy-の動作を見る)で紹介するデモ用の Company、Stays を使います。下の図は、User、その Personal Agent、Authlete を認可サーバーに使う Company の間のフロー全体を示しています。番号は以降のセクションに対応しています。Company の認可サーバーと API が Authlete を呼び出し、User に表示されるのは Company のページだけです。

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant P as Personal Agent
    participant C as Company
    participant AS as Company の認可サーバー
    participant A as Authlete

    Note over P,A: 1〜2. ディスカバリー
    P->>C: GET /.well-known/poppy.json
    P->>C: GET /.well-known/oauth-protected-resource
    P->>AS: GET /.well-known/oauth-authorization-server
    AS->>A: service/configuration
    AS-->>P: メタデータ（CIMD 対応、protected_resources）

    Note over P,C: 4. サインアウト状態の Session
    P->>C: API リクエスト + Poppy-Session
    C-->>P: 200、アカウント不要
    P->>C: アカウントが必要な API リクエスト + Poppy-Session
    C-->>P: 401、必要なスコープを提示

    Note over U,A: 3、5. エージェントの識別とサインイン
    P->>U: Company のサインインページを開く
    P->>AS: 認可リクエストをプッシュ（サーバーが PAR を提供している場合）
    AS->>A: pushed_auth_req
    AS-->>P: request_uri
    U->>AS: 認可リクエスト（client_id はエージェントの URL、prompt=consent）
    AS->>A: auth/authorization
    A->>P: エージェントのメタデータを取得（CIMD）
    A-->>AS: INTERACTION、エージェントを登録
    AS->>U: サインインと同意のページ
    U->>AS: サインインしてスコープを承認
    AS->>A: auth/authorization/issue
    AS-->>P: 認可コード付きでリダイレクト
    P->>AS: トークンリクエスト（認可コード、クライアントアサーション、任意で DPoP プルーフ）
    AS->>A: auth/token
    A-->>AS: アクセストークン（DPoP プルーフがあればエージェントの鍵に紐付け）
    AS-->>P: アクセストークンとリフレッシュトークン

    Note over P,A: 6. サインイン後のリクエスト
    P->>C: API リクエスト + Poppy-Session + トークン（+ DPoP プルーフ）
    C->>C: Poppy-Session ヘッダを確認
    C->>A: auth/introspection
    A-->>C: OK、User とスコープ
    C-->>P: レスポンス
```

### 1. ディスカバリ

エージェントは `https://stays.poppysandbox.dev/.well-known/poppy.json` を読み込みます。このファイルには、Company とその認可サーバーの情報、User に表示する言葉で書かれた各スコープの説明、API の一覧が記載されています。

```json poppy.json (抜粋) theme={null}
{
  "protocol_version": "1.0",
  "organization": { "name": "Stays", "domain": "stays.poppysandbox.dev" },
  "auth": {
    "issuer": "https://auth.stays.poppysandbox.dev",
    "scopes": {
      "stays:read": "See your Stays bookings.",
      "stays:write": "Book a room on your account. Each booking needs your approval."
    },
    "scope_hints": {
      "stays:read": { "changes": "none", "personal_data": true },
      "stays:write": { "changes": "irreversible", "personal_data": true }
    }
  },
  "apis": [
    { "type": "openapi", "url": "https://stays.poppysandbox.dev/openapi.json", "description": "Stays API" }
  ]
}
```

`scope_hints` は、スコープがデータを変更するか、その変更を取り消せるか、個人データに関わるかをエージェントに伝えます。この例では `stays:write` が `irreversible` なので、慎重なエージェントは予約の前に User に確認します。

どのチャネルを提供するかは Company が選びます。`poppy.json` には、`apis` (OpenAPI または MCP) のほかに、会話用の Company Agent (`agent`)、サインインした状態での Web サイトの利用 (`web`)、タスクに関するガイダンス (`tasks`) を記載できます。Stays が提供しているのは OpenAPI の API だけです。

### 2. 認可サーバーの確認

エージェントは発行者を二つの方法で確認します。まず、`https://stays.poppysandbox.dev/.well-known/oauth-protected-resource` にある Stays の保護リソースメタデータ ([RFC 9728][RFC_9728]) を読み込みます。

```json theme={null}
{
  "resource": "https://stays.poppysandbox.dev",
  "authorization_servers": ["https://auth.stays.poppysandbox.dev"]
}
```

次に、`https://auth.stays.poppysandbox.dev/.well-known/oauth-authorization-server` にある認可サーバーのメタデータ ([RFC 8414][RFC_8414]) を読み込みます。二つのドキュメントは互いを指していなければなりません。Company は自身の認可サーバーを示し、認可サーバーは `protected_resources` に Company を含めます。

| ファイル | 配置場所 | 作成者 |
| - | - | - |
| `/.well-known/poppy.json` | Company 自身のドメイン (`stays.poppysandbox.dev`) | 実装者 |
| `/.well-known/oauth-protected-resource` | Company 自身のドメインのルート | 実装者 |
| `/.well-known/oauth-authorization-server` | 認可サーバー (`auth.stays.poppysandbox.dev`) | Authlete がサービス設定から生成 |

Poppy では保護リソースはドメイン全体なので、そのメタデータはパスを付けずにルートに配置します。リソースが一つの URL である MCP サーバーとはこの点が異なります。

### 3. エージェントの識別

エージェントの `client_id` はメタデータを返す HTTPS URL です。仕組みは [CIMD](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/oauth-client-id-metadata-document-cimd.md) と同じです。メタデータにはエージェントの公開鍵 (`jwks_uri`) が含まれます。エージェントはトークンエンドポイントで署名付きのクライアントアサーション (`private_key_jwt`) を使って自身を証明します。エージェントは `exp` を `iat` から 5 分以内に設定しなければなりません。サービスは `ES256` と `PS384` で署名されたアサーションを受け入れ、`aud` が自社の発行者でないアサーションを拒否しなければなりません。Authlete では `clientAssertionAudRestrictedToIssuer` を有効にするとこの確認が行われます。この設定はデフォルトでは無効です。詳しくは [Authlete で Poppy を実装する](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/poppy-implementation.md#サービスを設定する) を参照してください。

Poppy では、エージェントがメタデータに署名アルゴリズムを記載する必要はありません。エージェントのメタデータに `token_endpoint_auth_signing_alg` がない場合でも、エージェントが公開している鍵のいずれかで検証できれば、Authlete はそのアサーションを受け入れます。アルゴリズムを記載したエージェントは、そのアルゴリズムで署名する必要があります。

### 4. サインアウト状態の Session

部屋の一覧表示など、アカウントを必要としない処理であれば、エージェントは誰もサインインしていない状態で Stays の API を呼び出せます。すべてのリクエストには `Poppy-Session` ヘッダが付きます。これはエージェントが短期間有効な鍵で署名した JWT で、その鍵は `jwks_uri` にあるエージェントの鍵の一つによって保証されます。このヘッダは、エージェント (`iss`)、Company (`aud`、その発行者)、User ID (`sub`)、Session (`sid`)、そしてリクエストそのもの (`htm` と `htu`) を示します。これらのリクエストには、`Poppy-Version: 1.0` のような `Poppy-Version` ヘッダも付きます。

アカウントが必要なリクエストに対して、Stays はエラーコードなしで `401` を返し、`WWW-Authenticate` チャレンジで必要なスコープを示します。

### 5. サインイン

User は Company 自身のページでサインインし、スコープを承認します。Poppy は二つのサインイン方法を定めています。

* **Direct Sign-In**: User がブラウザで Company のページにサインインします。これは [PKCE](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/proof-key-for-code-exchange-pkce.md) 付きの認可コードフローです。リクエストには `prompt=consent` が含まれるため、User は毎回エージェントを承認します。同意ページには、Company が付与するすべてのスコープを表示しなければなりません。Stays のように認可サーバーが Pushed Authorization Request（PAR）のエンドポイントを提供している場合、エージェントはまずそこにリクエストをプッシュし、返された `request_uri` だけを付けてブラウザを開くべきです。
* **Device Sign-In**: User は、エージェントが表示するリンクとコードを使って、任意のデバイスでサインインします。これは[デバイスフロー](https://developers.authlete.com/ja/protocols-and-flows/advanced-flows/oauth-2-0-device-authorization-grant-device-flow.md)です。

### 6. サインイン後のリクエスト

エージェントはアクセストークンと `Poppy-Session` ヘッダを一緒に送信します。Company は両方を確認してから処理を実行します。アクセストークンは Bearer トークンでも [DPoP](https://developers.authlete.com/ja/configuration-reference/tokens-and-claims/using-dpop.md) に紐付いたトークンでもよく、どちらにするかは Company が選びます。Personal Agent は DPoP に対応するべきです。

サインアウトするには、エージェントは Company について保持しているすべてのリフレッシュトークンを失効エンドポイントで失効させます。

## Authlete が担う部分

| Poppy の要件 | 標準仕様 | 担当 |
| - | - | - |
| エージェントが URL で自身を識別する | [CIMD](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/oauth-client-id-metadata-document-cimd.md) | Authlete がエージェントのメタデータを取得、検証、登録します |
| エージェントが署名付きアサーションで認証する | [`private_key_jwt`](https://developers.authlete.com/ja/configuration-reference/endpoints/client-authentication-using-private-key-jwt-method) | エージェントが署名アルゴリズムを記載しているかどうかにかかわらず、Authlete がエージェントの公開鍵でアサーションを検証します |
| Direct Sign-In | PKCE 付きの認可コードフローと Pushed Authorization Request（PAR） | Authlete がリクエストを処理します。サインインと同意のページは実装者が作成します |
| Device Sign-In | [デバイスフロー (RFC 8628)](https://developers.authlete.com/ja/protocols-and-flows/advanced-flows/oauth-2-0-device-authorization-grant-device-flow.md) | Authlete がリクエストを処理します。検証ページは実装者が作成します |
| リフレッシュトークンと失効 | RFC 6749, RFC 7009 | Authlete |
| 送信者制約付きアクセストークン (任意) | [DPoP](https://developers.authlete.com/ja/configuration-reference/tokens-and-claims/using-dpop.md) | Authlete がトークンを紐付けて検証します |
| 認可サーバーのメタデータ | RFC 8414 | Authlete がサービス設定から生成します |
| `poppy.json` と保護リソースメタデータ | Poppy, RFC 9728 | 実装者が Company のドメインで公開します |
| `Poppy-Session` ヘッダの検証 | Poppy | 実装者が API で検証します |

> [!NOTE]
>
> Poppy では、認可サーバーのメタデータの `protected_resources` に Company が含まれている必要があります。Authlete 3.0.40 以降では、サービス設定の **Protected Resources** (`protectedResources`) を設定すると、Authlete がこれを含めます。それより前のバージョンでは、ディスカバリエンドポイントでレスポンスを返す前に Company の URL を追加してください。

## Poppy の動作を見る

実際の利用場面でフローを確認するために、このセクションでは海辺の部屋を貸し出すデモ用の企業 **Stays** を使います。Stays は Authlete で保護された完全な Poppy Company です。認可サーバーは OAuth の各ステップで Authlete を呼び出し、API はすべてのアクセストークンについて Authlete に問い合わせます。あなたは顧客の立場で、自分の Personal Agent が Stays を見つけ、サインインさせ、部屋を予約する様子を見ながら、[上のフロー](#poppy-の仕組み)の各ステップを確認します。

> [!TIP]
>
> アカウントを作らずに概要をつかむには、\[Poppy デモ]\[DEMO]をお試しください。フロー全体をブラウザで順に再生し、続いて構築する各エンドポイントのコードを示します。

Stays は自社のブランドとドメインを保ち、Authlete はその背後で動作します。顧客に表示されるのは Stays のページだけです。

| ホスト | 提供する内容 |
| - | - |
| `stays.poppysandbox.dev` | Web サイト、`poppy.json`、保護リソースメタデータ、Stays API |
| `auth.stays.poppysandbox.dev` | Authlete を呼び出す薄いレイヤーとしての認可サーバー |
| `account.stays.poppysandbox.dev` | Stays 自身のサインインと同意のページ |

![Stays のトップページ](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/stays-home.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=4e5de929a7c6d9f1c38ab9b554915b20)

次の二つのエージェントでフローを確認できます。

| エージェント | 作成者 | 確認できること |
| - | - | - |
| [Poppy Agent Playground][PLAYGROUND] | Authlete | フローの各ステップと、デコードされた各リクエスト |
| [Poppy Simulator][SIMULATOR] | Stacktree（独立） | 第三者が作成したエージェントが、Authlete で保護された Company と連携できること |

### 事前準備

* [Stays のサインインページ](https://account.stays.poppysandbox.dev/auth/sign-in)の **Sign Up** でテスト用アカウントを作成してください。Stays はデモなので、実際の個人情報は使用しないでください。
* Playground と Simulator はブラウザで動作するため、インストールは不要です。

### Poppy Agent Playground でフローをたどる

[Poppy Agent Playground][PLAYGROUND] は、タスクを一つずつ選んで操作する Personal Agent です。各タスクは Stays への実際のリクエストで、左側ではエージェントが平易な言葉で応答し、右側の **Wire** にはすべてのリクエストがデコードされて表示されます。目標は部屋を予約することです。以下のステップ番号は、[Poppy の仕組み](#poppy-の仕組み)の図に対応しています。

**1. Stays を検出する（ステップ 1 と 2）**

上部の入力欄に `stays.poppysandbox.dev` を入力し、**Discover** をクリックします。Playground は Stays の `poppy.json` と保護リソースメタデータ、Authlete が `auth.stays.poppysandbox.dev` 用に生成した認可サーバーのメタデータ、OpenAPI ドキュメントを読み込みます。**Your agent** に *Connected to Stays* と表示され、**Call an API** には Stays の操作が、それぞれに必要なスコープとともに一覧表示されます。

![Stays に接続した Playground](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-discover.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=5b23c3d1351a2b43d38d4cbabbd7c2b9)

**2. 空いている部屋を検索する（ステップ 4）**

**GET /rooms**（*Search available rooms*）を選び、**Send** をクリックします。検索にはアカウントが不要なので、サインアウト状態の Session で十分です。エージェントは Stays の二つの部屋を表示します。

![サインアウト状態で Stays の部屋を一覧表示するエージェント](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-rooms.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=37d8730ff5331c7347272c26174a3a15)

**3. 予約の一覧を表示しようとする（ステップ 4）**

**GET /stays**（*List your bookings*）を選び、**Send** をクリックします。Stays は `401` を返し、エージェントは Stays が `stays:read` を必要としているため先にサインインする必要があると応答します。**Wire** でリクエストをクリックすると、`Poppy-Session` ヘッダ、その委任 (`poppy_dlg`)、Stays のレスポンスが表示されます。

![デコードされたサインアウト状態での予約一覧のリクエスト](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-wire.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=c0a6779794831997a6c8f17bfb731c8a)

**4. Stays にサインインする（ステップ 3 と 5）**

**Sign in to Stays** をクリックすると、Stays 自身のサインインページが新しいタブで開きます。Playground には Stays が求めているアクセスが表示され、そのページは Authlete が支える Stays 自身の認可サーバーであることが示されます。

![Stays のサインインページに案内する Playground](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-sign-in.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=23bbe21897c108e1d0c53faa7c296b76)

テスト用アカウントでサインインし、Stays のページでスコープを承認します。

![Stays のサインインページ](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/stays-sign-in.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=be8f6c96fab4ad97f69f115347c0f34f)

その裏で、Playground はまず Stays の認可サーバーにリクエストをプッシュします（`POST /oauth/par`）。Authlete は Playground のメタデータを取得して登録し（CIMD）、認可コードを発行します。Playground が認可コードを交換するとき（`POST /oauth/token`）、Authlete は署名付きのクライアントアサーションを検証し、トークンを発行します。

**5. サインインした状態で予約を一覧表示する（ステップ 6）**

エージェントは *Signed in. Stays granted me the access you approved.* と応答し、もう一度予約を一覧表示します。今回はリクエストに `Poppy-Session` ヘッダとアクセストークンが付き、Stays は `200` を返します。まだ予約はありません。

![サインインしたエージェントと、Wire 上のアクセストークン](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-signed-in.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=f863094dd95510b6eb321c369869f72f)

**6. 部屋を予約する（ステップ 6）**

**POST /stays**（*Book a room*）を選びます。必要に応じてボディを編集し（例: `{ "room": "sea-view", "checkIn": "2026-12-01", "nights": 2 }`）、**Send** をクリックします。Stays が `Poppy-Session` ヘッダを、Authlete がアクセストークンとその `stays:write` スコープを確認し、Stays は予約の ID、合計金額、キャンセルポリシーとともに `201` を返します。

![予約を確定する Stays](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-booked.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=63ddf154c3b854750b87bb79a21839c6)

**7. 予約を確認する**

もう一度 **GET /stays** を選ぶと、予約した部屋がエージェントに一覧表示されます。

![新しい予約を一覧表示するエージェント](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/playground-my-bookings.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=05e9e41e1504f2cdff28f32250aa2527)

**Sign in with a code** では、代わりに Device Sign-In でサインインします。下部の **Agent settings** には、エージェントの識別子とトークンの種類が表示されます。デフォルトでは、自身でホストする CIMD の識別子と DPoP に紐付いたトークンです。そこで **Sender-constrained tokens (DPoP)** をオフにすると Bearer トークンになります。Stays はどちらも受け入れます。

### Poppy Simulator で独立したエージェントの動作を見る

[Poppy Simulator][SIMULATOR] は、Stacktree が Authlete や Stays のコードを使わずに仕様書だけを基に作成した、ホスト型のテスト用エージェントです。Poppy 1.0 とドラフト 0.2 から 0.4 に対応し、Company が提供する最新のバージョンを使用します。Authlete や Poppy の作成者とは関係ありません。

**1. チェックを実行する**

**Test a company** を選び、`stays.poppysandbox.dev` を入力して **Run the checks** をクリックします。Simulator は Stays のディスカバリーファイルを読み込み、サインアウト状態の Session を開始し、Company が拒否しなければならないリクエストを送信します。

**2. 結果を確認する**

各チェックには検証対象の仕様のセクションが示され、結果は成功 (✓)、警告 (!)、失敗 (×)、情報 (i) のいずれかです。**The wire** には、すべてのリクエストとそのチェックが表示されます。

![Stays に対する Simulator のチェック結果](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/simulator-checks.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=071f9145c536b6275126e1a37c7c8239)

**3. サインインする**

Direct Sign-In では **Sign in on this device** を選びます。Simulator はまず Stays の認可サーバーにリクエストをプッシュし（Pushed Authorization Request）、続いて Stays のサインインページを開きます。テスト用アカウントでサインインし、Stays の同意ページでスコープを承認します。

**4. トークンの交換を確認する**

Simulator に戻ると、Wire にフローの残りが表示されます。各ステップは Stays の認可サーバーを通り、処理は Authlete に任されています。

* 認可コードとともに返される `state` と `iss` が、Simulator の想定と一致します。
* 認可コードがアクセストークンとリフレッシュトークンに交換されます。Authlete は Simulator の署名付きクライアントアサーションを受け入れ、要求されたもの以外のスコープは付与しません。
* 同じ認可コードをもう一度交換しようとすると拒否されます。
* リフレッシュトークンで、`stays:read` に絞り込んだ新しいアクセストークンを取得します。

  ![Simulator による Stays へのサインインとトークンの交換](https://mintcdn.com/authlete/iIxpPE74KF_xTx8r/img/developers/poppy/simulator-sign-in.png?fit=max\&auto=format\&n=iIxpPE74KF_xTx8r\&q=85\&s=4eafc963cb5286fbbbc820c94c9c4c73)

> [!NOTE]
>
> Stacktree によると、Simulator は何も公開せず、フィードバックは Stacktree にのみ送信します。

### 自社の Company で同じデモを実行する

[Authlete で Poppy を実装する](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/poppy-implementation.md)に従って Company を構築したら、同じエージェントを自社のドメインに向けてください。

* Company のドメインは、インターネットから HTTPS でアクセスできる必要があります。Playground と Simulator はホスト型のサービスとして動作するため、`localhost` にはアクセスできません。
* サービスで CIMD の許可リストを使用している場合は、エージェントのクライアント ID を追加してください。

| エージェント | クライアント ID |
| - | - |
| Poppy Agent Playground | `https://poppy-playground.authlete.app/agent.json` |
| Poppy Simulator | `https://poppy-simulator.stacktr.ee/agent.json` |

* サインインページ用のテスト User アカウントを用意してください。

各ステップで確認すべき内容は、次のチェックリストのとおりです。

## チェックリスト

どのツールでも、次の項目で確認してください。セクション番号は [Poppy 1.0 仕様][POPPY_SPEC]のものです。

| 確認項目 | 期待される結果 | セクション |
| - | - | - |
| `poppy.json` が `/.well-known/poppy.json` で HTTPS により提供される | JSON とともに `200` | 3 |
| `organization.domain` が `poppy.json` を提供するホストと一致する | 完全一致 | 3.1 |
| `supported_versions` に、提供している他のバージョンだけが記載されている | 自身の `protocol_version` は含まれない | 3.4 |
| 保護リソースメタデータの `resource` | `https://{organization.domain}` と完全一致 | 3.2 |
| 認可サーバーのメタデータの `issuer` | `poppy.json` の発行者と完全一致 | 3.2 |
| 認可サーバーのメタデータの `protected_resources` | `https://{organization.domain}` を含む | 3.2 |
| `grant_types_supported` | `refresh_token` を含み、記載したすべてのグラントが動作する | 3.2 |
| 認可サーバーのメタデータの `revocation_endpoint` | 記載されている | 3.2 |
| エージェントが `ES256` または `PS384` でアサーションに署名する | エージェントのメタデータにアルゴリズムの記載がなくても受け入れられる | 4.1 |
| 未知のスコープを含むサインインリクエスト | `invalid_scope` で拒否される | 4.7 |
| 各スコープヒントに `changes` と `personal_data` がある | 両方の項目がある | 4.7 |
| 同意ページ | Company が付与するすべてのスコープを表示する | 10.8 |
| 有効な `Poppy-Session` ヘッダのないリクエスト | `invalid_session` とともに `400` | 5.3 |
| アカウントが必要な処理へのサインアウト状態のリクエスト | エラーコードなしの `401`。`WWW-Authenticate` チャレンジで必要なスコープを示す | 7 |
| スコープが不足しているサインイン後のリクエスト | `insufficient_scope` とともに `403` | 7 |
| DPoP に紐付いたアクセストークンを DPoP プルーフなしで送信する | `401` | 4.5、RFC 9449 |

## トラブルシューティング

| 症状 | 原因 | 対処 |
| - | - | - |
| サインインが `A505301` で失敗する | Authlete がエージェントのメタデータを取得できない | エージェントの `client_id` の URL が HTTPS で公開されている必要があります |
| サインインが `A505306` で失敗する | エージェントの `token_endpoint_auth_method` をサービスがサポートしていない | `supportedTokenAuthMethods` に `PRIVATE_KEY_JWT` を追加します |
| サインインが `A505307` で失敗する | エージェントのメタデータの値 (通常はグラントタイプ) をサービスがサポートしていない。Poppy Simulator はデバイスグラントと JWT Bearer グラントを記載している | メタデータポリシーでグラントタイプを除外します。`supportedGrantTypes` に追加するのは、そのグラントを提供する場合だけです。`DEVICE_CODE` の場合は Device Sign-In を構築する必要があります |
| サインインが `A011317` で失敗する | `redirect_uri` がエージェントのメタデータに記載されていない | エージェントは記載したリダイレクト URI を使用する必要があります |
| トークンリクエストが `A157306` で失敗する | サービスがサポートしていないアルゴリズム、またはエージェントのメタデータに記載したものとは異なるアルゴリズムでアサーションが署名されている | サービスが `ES256` と `PS384` をサポートしていることを確認します。アルゴリズムを記載したエージェントは、そのアルゴリズムで署名する必要があります |
| Device Sign-In が `A222101` で失敗する | `deviceVerificationUri` が設定されていない | 設定するか、`supportedGrantTypes` から `DEVICE_CODE` を削除します |
| 正当なエージェントに API が `invalid_session` を返す | `Poppy-Session` ヘッダの検証が厳しすぎる | `aud` を発行者と、`htu` をリクエストの公開 URL と比較しているか確認します |

## 次のステップ

自社の Company を Personal Agent と連携させるには、[Authlete で Poppy を実装する](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/poppy-implementation.md)をご覧ください。Authlete サービスの設定、`poppy.json` の公開、サインイン、トークン、`Poppy-Session` ヘッダの処理を順を追って説明します。

## 参考資料

* [Personal Agent Protocol][POPPY_SITE]
* [Personal Agent Protocol 仕様 バージョン 1.0][POPPY_SPEC]
* [Personal Agent Protocol 変更履歴][POPPY_CHANGELOG]
* [Company implementation kit][KIT]
* [Releasing Personal Agent Protocol 1.0 (Sierra)][SIERRA_RELEASE]
* [RFC 8414: OAuth 2.0 Authorization Server Metadata][RFC_8414]
* [RFC 9728: OAuth 2.0 Protected Resource Metadata][RFC_9728]
* [OAuth Client ID Metadata Document (CIMD)](https://developers.authlete.com/ja/protocols-and-flows/protocol-extensions/oauth-client-id-metadata-document-cimd.md)
* [Poppy Agent Playground][PLAYGROUND]
* [Poppy Simulator (Stacktree)][SIMULATOR]

[POPPY_SITE]: https://personalagentprotocol.org/

[POPPY_SPEC]: https://personalagentprotocol.org/docs/1.0/spec

[POPPY_CHANGELOG]: https://personalagentprotocol.org/docs/changelog

[KIT]: https://personalagentprotocol.org/kit/company

[SIERRA_RELEASE]: https://sierra.ai/blog/releasing-poppy

[RFC_8414]: https://www.rfc-editor.org/rfc/rfc8414.html

[RFC_9728]: https://www.rfc-editor.org/rfc/rfc9728.html

[PLAYGROUND]: https://poppy-playground.authlete.app

[SIMULATOR]: https://poppy-simulator.stacktr.ee

[DEMO]: https://demo.poppysandbox.dev/


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