API-39Required
Grant narrow scopes
Give each token only the scopes its job needs, and check the scope on every endpoint.
How to do it
Define scopes per resource and action, such as orders:read and orders:write. Declare the scope each operation needs in the contract. Answer 403 with a problem naming the missing scope, and with WWW-Authenticate: Bearer error="insufficient_scope" as RFC 6750 defines.
How to check
Call POST /orders with an orders:read token. The answer is 403 and names orders:write.
Sources
Related rules
- WEB-173 Publish your sign-in server settings in Website
- ACC-39 Limit tokens and agents to what their owner may do in Accounts and identity
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/api-security/token-scopes">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.