stackwell.tech
Guides / Getting started

Getting started

Your first authorized call, end to end. The platform splits who you are from what you may do — so this guide is three steps: prove identity with Chirp, get permission from Granite, then call a service like Drive — with both checked.

The model in one minute

One rule explains the whole platform:

⊢
The rule
A token proves who you are. It never grants what you may do.
  Chirp (identity)        Granite (permission)        Service (Drive, …)
  ───────────────         ────────────────────         ──────────────────
  who you are    ─token─▶  user approves ─grant─▶  verifies token + grant
                                                    then acts (or refuses)

Step 1 — Get an identity (a Chirp token)

First register a client with Chirp to get a client_id — a confidential client for a service or agent, or a public client (PKCE) for user login. Then authenticate:

A service or agent acting as itself uses the OAuth2 client_credentials grant:

curl -X POST https://signin.chirpauth.com/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -d grant_type=client_credentials

A human signs in with OIDC Authorization Code + PKCE (browser) or the device-code flow (CLI). Either way you get a signed token, verified against GET /jwks.json.

Three things to know about Chirp tokens: each relying party sees a different (pairwise) sub for the same person, tokens carry no email, and roles like operator are resolved live — never baked into the token. See the Chirp docs and the Identity Protocol.

Step 2 — Get permission (a Granite grant)

To act on a user's resource (say, write to their Drive), you need their consent. File an approval request with Granite, authenticated with your token:

curl -X POST https://granitegranted.com/v1/approval-requests \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... who is asking, to do what, on which resource, at what scope ... }'

The user sees the request in their Granite inbox — who is asking, to do what, with what reach, how risky — and approves or denies. On approval, Granite mints a revocable, scoped grant (a grant_id). The user can revoke it later, and the next call that relies on it is refused. (For first-party cases — the authority-holder acting on their own resource — execution is the approval and no prompt is needed; agents and destructive actions always require a grant.) Exact request fields are in the Granite API reference; the model is the Approval Protocol.

Step 3 — Call the service with token + grant

Now make the real call, presenting your identity and the grant. Drive reads the grant from the x-granite-grant header:

curl -X POST https://<your-drive-endpoint>/v1/... \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-granite-grant: $GRANT_ID" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

Drive verifies the token (who you are) and consults Granite to verify the grant (what you may do) before acting — failing closed if either is missing, mismatched, or revoked. That's the whole loop: revoke the grant in Granite and this exact call stops working on its next attempt. See the Drive API reference for the per-endpoint scopes.

If you're building a service (verifying tokens)

Don't hand-roll verification. The chirp-auth-client crate verifies the signature, issuer, audience, and environment (a test token can't pass at a production relying party, by construction) and hands you the identity. Pass your accepted machine audiences to it rather than maintaining your own allowlist. And the golden rule: gate every action on a Granite grant, never on the token alone.

Next steps