EC-CUBE / EC-CUBE/eccube-api4

エージェントコマース: クライアント登録完了画面にトークン取得例 (scope の指定方法) を追記する

Open Beginner friendly
#194 0 comments 0 reactions 0 assignees View on GitHub
documentation enhancement
Dominant language
PHP
Stars
9
Forks
18
PR merge metrics
No merged PRs in 30d

Description

## 背景

#191 のレビュー ([#discussion_r3732470588](https://github.com/EC-CUBE/eccube-api4/pull/191#discussion_r3732470588)) から切り出しました。

ACP/UCP クライアント (`client_credentials`) でトークンを取得する際、エージェント事業者から見て `scope` の指定方法が分かる導線がありません。現状の挙動は次のとおりです。

| 送信内容 | 結果 |
|---|---|
| `scope` 省略 | 200 / クライアントが保有する scope がすべて付与される (`ScopeRepository::setupScopes()` の `empty($requestedScopes)` 分岐でクライアント scope をそのまま返すため) |
| `scope=acp:checkout` のようにクライアント保有 scope を明示 | 200 / 明示した scope のみ付与 |
| クライアントが保有しない scope を明示 (例: `scope=read`) | `invalid_scope` |

動作としては問題ありませんが、登録完了画面 (`agent_commerce_client_issued.twig`) にはクライアント ID とシークレットしか表示されないため、事業者へ渡す際に「このシークレットでどうトークンを取るのか」が伝わりません。

## やりたいこと

登録完了画面に `POST /token` の要求例を追記する。

- `grant_type=client_credentials` であること
- `scope` に何を指定できるか (そのクライアントに付与した scope)
- `scope` を省略した場合は付与済み scope が全付与されること

`curl` 例をそのまま貼れる形にしておくと、事業者への連携がそのまま行えて親切だと思います。

## 補足

`scopes.default: ['read']` はトークン発行経路とは無関係で、`AddClientDefaultScopesListener` (クライアント保存時に scope 未指定なら既定を入れる) にのみ効きます。レビュー中に私が誤解した点なので、あわせて記録しておきます。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with templates/agent_commerce_client_issued.twig, the registration completion view named in the issue, and review the POST /token request details. Add a copyable curl example showing client_credentials, available client scopes, and the behavior when scope is omitted; the page should explain how the issued credentials are used to obtain a token.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.