What it demonstrates
- Registering an agent from a server-side API route
- Creating an authorization request with a redirect URI
- Redirecting to the Grantex consent UI
- Exchanging the authorization code for a grant token
- Logging an audit entry after token exchange
- Displaying grant details and audit trail in a callback page
Quick start
Flow overview
Project structure
Environment variables
| Variable | Description | Default |
|---|---|---|
GRANTEX_API_KEY | Your Grantex API key | (required) |
GRANTEX_URL | Auth service base URL | https://grantex-auth-dd4mtrt2gq-uc.a.run.app |
NEXT_PUBLIC_APP_URL | Public URL of this app (for redirect URI) | http://localhost:3000 |
Key design decisions
- Server-side SDK only — All Grantex SDK calls happen in API routes. The API key never reaches the browser.
- Cookie-based state —
agentIdand a randomstateare stored in cookies before redirect, then verified on the callback to prevent CSRF. - Fresh agent per demo — Each click registers a new agent. No database required.
- No UI libraries — Minimal CSS matching the grantex.dev branding.