ErrorsSign-in and identity · rule
type.token_scopes_invalid
Code gives sessions.issue_token scopes: that aren't a list of scopes api_token: { scopes: } declares.
Area 8, Sign-in and identity; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
sessions.issue_token(user_id, scopes: [OAuthScope.<name>]) issues an
API token narrowed to the scopes listed, which policy then holds it to,
as it holds a provider's narrowed token
(Scopes). Each must be one
api_token: { scopes: } declares, listed once, and at least one. A
token with no scopes: may do whatever its person may.
What it looks like
main.jadpo:
principal { user: { subject: Member.handle }}authentication { api_token: {}}type Handle = Text { max_length: 40}entity Member { id: Uuid handle: Handle { unique: true } policy: { create: [Access.public] read: [id] }}type AppSignedIn = Output { token: ApiToken}/// A token for the member's app that may only read.action reading_token(member: Principal.user) -> AppSignedIn { return AppSignedIn { token: sessions.issue_token(member.id, scopes: [OAuthScope.notes_read]) }}
error sessions.issue_token is given scopes, and api_token: declares none
--> main.jadpo:34:56
|34 | token: sessions.issue_token(member.id, scopes: [OAuthScope.notes_read]) | ^^^^^^^^^^^^^^^^^^^^^^^ no scopes declared
- reason
sessions.issue_token(user_id, scopes: [OAuthScope.<name>])narrows the token to the scopes listed, each oneapi_token: { scopes: }declares, once; leavescopes:out for a token that may do whatever its person may.api_token:inauthentication { }declares noscopes:, so there is nothing to narrow a token to.- next
- Declare the scopes in
api_token: { scopes: { <name>: "<scope-token>" } }, or removescopes:(agent) - rule
- type.
token_ scopes_ invalid - help
- https://jadpo.
dev/docs/errors/type. token_ scopes_ invalid
(agent) at the end of the next: line means your coding agent can make
the fix itself: it declares the scope.
How to fix it
If the token should carry notes_read, declare it in api_token:,
with the scope-token the token carries for it:
authentication { api_token: { scopes: { notes_read: "notes:read" } }}
The token is now narrowed to notes:read, and policy holds it to the
grants whose effects name that scope.
Related
Markdown for agents: /docs/errors/type.token_scopes_invalid.md.Built from Jadpo's main branch at commit 9080dc3.