api-tokens.verify/v1

Another server checks one of an app's API tokens. A host in front of an app's accounts (a PocketHost edge in front of the mothership) is handed a token by a client and asks the app that issued it who the token acts as and what it may do. Companion to api-tokens/v1: whatever provides that provides this.

A wire contract (verify.go).

Use

Operation HTTP Who
Verify POST /api/_c/api-tokens.verify/v1 {"token", "ip"} superusers (api_tokens_verify)

ip is the client's address, recorded as the token's last use; leave it out to leave the last use alone.

A valid token:

{"valid": true, "grant": {"tokenId": "...", "name": "ci", "ownerCollection": "users", "ownerId": "...",
  "scopes": ["instances=abc123"]}}

scopes empty means the owner's full rights; a scope with a value (instances=abc123) holds it for that value only (see api-tokens/v1). A token that isn't valid is an answer, not an error, so a caller can tell a refused token from an outage: {"valid": false, "reason": "invalid"} (unknown, malformed or revoked) or "expired".

In Go, from the other server:

c := verifyv1.NewClient("https://app.example.com", superuserToken, nil)
res, err := c.Verify(ctx, extkit.Auth{}, verifyv1.Input{Token: token, IP: ip})
if err != nil { /* the app is unreachable: don't treat the token as refused */ }
if !res.Valid { /* 401: res.Reason */ }
if !res.Grant.HasScopeFor("instances", id) { /* 403 */ }

Cache answers briefly if you verify on every request: a revoked token then stops working once its entry expires.

Provide

Implement verifyv1.Verifier over the same tokens as your api-tokens/v1 provider. Never return an error for a token that isn't valid: return Valid: false and a reason.

Commands and APIs

Every operation is a REST endpoint, a pocketone command and an MCP tool, all generated from the contract and behind the same token scope check and hooks. See Remote CLI, or the full CLI, Extension APIs and MCP references.

verify

Checks an API token and says who it acts as and what it may do (its scopes, with their values). A token that isn't valid is an answer (Valid false), not an error, so callers can tell a refused token from an outage.

REST POST /api/_c/api-tokens.verify/v1
CLI pocketone remote api-tokens verify --token <value> --ip <value>
MCP api-tokens_verify_verify
Token scope api_tokens_verify
Input field Flag Type
token --token string
ip --ip string

Extensions

Extension
api-tokens provides

License

MIT