Live Grants, Refresh Rotation, Revocation & Vault Export
Read live context updates via GET /api/v0/context and /oidc/userinfo, rotate offline_access refresh tokens, revoke tokens with RFC 7009, and export full vaults via /api/v0/export.
A Protext grant is live: edit an approved item once in your vault and allowed apps fetch the current value via GET /api/v0/context or /oidc/userinfo—until you revoke the grant in one click or export your entire vault at /api/v0/export.
Access tokens last 1 hour (3600s) and refresh tokens (issued with offline_access) last 90 days and rotate on every refresh. Revoking a grant in /me/apps kills every token minted from it immediately, and relying parties can self-revoke tokens via RFC 7009 POST /oidc/revoke.
Lifecycle endpoints for live reads, token refresh, revocation, and export
| Operation | Endpoint & Method | Auth & Response behavior |
|---|---|---|
| Read live bundle | GET /api/v0/context | Authorization: Bearer <access_token>; returns current JSON bundle (or RS256 JWT with ?format=jwt), Cache-Control: no-store |
| Read OIDC + bundle | GET or POST /oidc/userinfo | Authorization: Bearer <access_token>; returns sub, standard OIDC claims, protext_handle, protext_url, and protext bundle |
| Rotate refresh token | POST /oidc/token (grant_type=refresh_token) | Deletes old refresh token, mints new 1h access + 90d refresh token, returns fresh id_token, context, and context_token |
| RP token revocation | POST /oidc/revoke (RFC 7009) | Form body token=<raw_token>; deletes token hash and always returns HTTP 200 |
| User grant revocation | /me/apps dashboard | Deletes grant; lookupToken immediately rejects all tokens for that grant with HTTP 401 |
| Full vault export | GET /api/v0/export | Authenticated vault session; downloads <handle>.protext.json with all items and visibility flags |
Reading live context, rotating a refresh token, and revoking via RFC 7009
Exact request shapes supported by app/api/v0/context, app/oidc/token, and app/oidc/revoke.
# 1. Fetch the current live bundle under an active grant
curl -H "Authorization: Bearer $ACCESS_TOKEN" \
https://protext.org/api/v0/context
# 2. Rotate a refresh token (requires offline_access scope)
curl -X POST https://protext.org/oidc/token \
-H "content-type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token&refresh_token=$REFRESH_TOKEN&client_id=$CLIENT_ID"
# 3. Revoke a token from the relying party side (RFC 7009)
curl -X POST https://protext.org/oidc/revoke \
-H "content-type: application/x-www-form-urlencoded" \
-d "token=$ACCESS_TOKEN"How live grants stay bounded and predictable
Every call to GET /api/v0/context, /oidc/userinfo, or grant_type=refresh_token queries the person's current vault items intersected with grant.itemIds and token.scopes. That gives people a "update once, carry everywhere" experience for items they already approved, while ensuring newly created items never leak silently.
Both access tokens and refresh tokens are opaque 32-byte random values stored solely as SHA-256 hashes in Postgres. On every refresh request, the presented refresh token is deleted and replaced with a newly minted refresh token, returning an updated id_token, context, and context_token together.
Revocation and mandatory portability (§6.4)
SPEC.md §1.1 states plainly: "A provider that cannot be left is not a Protext provider." On the reference provider, GET /api/v0/export downloads the entire vault—including every item's provenance and visibility setting—as a single <handle>.protext.json bundle with Cache-Control: no-store.
When a person revokes an app under /me/apps, lookupToken() checks the grant row on every bearer or refresh lookup, so every outstanding access token and refresh token fails immediately with HTTP 401 invalid_token. Relying parties should also call POST /oidc/revoke (RFC 7009) when a user disconnects or deletes their account inside the RP.
- GET /api/v0/context and /oidc/userinfo return CORS headers so browser apps with a valid access token can re-read live context via Protext.context(accessToken).
- Every live read is appended to the person's access log with the relying party ID and item count.
- RFC 7009 revocation always responds with HTTP 200 regardless of whether the token existed or was already revoked.
Verify against the normative specification or register your client.
Frequently asked questions
How does a relying party request a refresh token in Protext?
Include offline_access in the authorization scope parameter. Token exchange then returns a 90-day refresh_token that rotates on every grant_type=refresh_token call.
What happens immediately after a user revokes an app in /me/apps?
Every access token and refresh token minted under that grant stops working immediately because lookupToken() verifies the grant row exists on every API call and returns 401 when revoked.
What does GET /api/v0/export include?
For an authenticated vault owner, GET /api/v0/export downloads <handle>.protext.json containing the PROTEXT/0.1 envelope, sub, handle, issued_at, every vault item with its source provenance and visibility flag, and personhood.
Why does POST /oidc/revoke return HTTP 200 even for unknown tokens?
That follows RFC 7009: revoking an already-revoked or unknown token produces the same HTTP 200 outcome so the endpoint does not leak token validity.
Does refreshing a token also return updated context?
Yes. Under SPEC.md §6.3 and app/oidc/token/route.ts, a refresh_token grant returns a rotated refresh_token, a fresh access_token, an updated id_token, and fresh context and context_token bundles.
Are access tokens JWTs or opaque tokens?
Access tokens and refresh tokens are opaque random tokens stored as SHA-256 hashes in the provider database (§9). Only id_token and context_token are RS256 JWTs.
Continue exploring PROTEXT/0.1
Signed context_token & JWKS Verification
Verify RS256 signed id_token and context_token JWS payloads against /.well-known/jwks.json using standard JOSE libraries for verifiable third-party bundle handoff.
Read guide →OpenID Connect & OAuth 2.1 PKCE Integration
Integrate Sign in with Protext using OpenID Connect Core discovery, OAuth 2.1 authorization code flow with S256 PKCE, RFC 9207 iss checks, and RS256 ID tokens.
Read guide →Self-Hosting a Protext Provider & Multi-Provider Discovery
Deploy your own MIT-licensed PROTEXT/0.1 provider with Next.js 15, Postgres, Drizzle, and PROTEXT_JWK, and implement /.well-known/protext.json multi-provider discovery.
Read guide →