Runnable examples for Go and TypeScript

Generated from the examples/ directories of theauth-go (32) and theauth (19). Run commands from a clone of the repository. Snapshot of main at c1ec752 and 5d81d947, taken 2026-10-31.

Go examples TypeScript examples

Go examples

Memory storage keeps most of them dependency free. Examples with their own go.mod run from inside their directory. Start with single-binary-sqlite for a complete app. See the Go library page for the install path.

  • agent-policy

    An autonomy denylist enforced as an IAM Deny: the token endpoint refuses to mint a denied action, whatever the agent prompt says.

    go run ./examples/agent-policy
    View on GitHub
  • agent-tool-guard

    A framework-agnostic tool guard: a refund tool runs freely for small amounts and needs a single-use human approval above a threshold.

    go run ./examples/agent-tool-guard
    View on GitHub
  • audit-receipts-go

    A signed audit checkpoint, a portable receipt and a consistency proof over a chained SQLite audit log.

    cd examples/audit-receipts-go && go run .
    View on GitHub
  • chi-app

    Minimal runnable example demonstrating magic-link auth.

    cd examples/chi-app && go run .
    View on GitHub
  • cli-device-login

    Sign a CLI in with the RFC 8628 device grant: a short code and URL, approval on any device, and the CLI polls until tokens arrive.

    go run ./examples/cli-device-login
    View on GitHub
  • cli-login

    A host CLI that authenticates against a theauth-go server with RFC 8628 device login, using the clientauth package.

    go run ./examples/cli-login
    View on GitHub
  • doctor-admin

    Serves /healthz publicly and a root-only /admin/security page that renders the report from Doctor, the configuration auditor.

    go run ./examples/doctor-admin
    View on GitHub
  • echo-app

    theauth-go behind an Echo v4 router, mounted on a chi subrouter and wrapped with echo.WrapHandler.

    cd examples/echo-app && go run .
    View on GitHub
  • gin-app

    theauth-go inside a Gin router, mounted on a chi subrouter and wrapped with gin.WrapH.

    cd examples/gin-app && go run .
    View on GitHub
  • github-actions-oidc

    GitHub Actions OIDC login, end to end and offline.

    go run ./examples/github-actions-oidc
    View on GitHub
  • hooks

    Wires every Config.LifecycleHooks callback to a log line so you can see when each one fires.

    go run ./examples/hooks
    View on GitHub
  • mcp-server

    A small MCP resource server built on the separate mcpresource module.

    cd examples/mcp-server && go run .
    View on GitHub
  • oauth-apple

    Sign in with Apple using the provider/apple package.

    cd examples/oauth-apple && go run .
    View on GitHub
  • oauth-bitbucket

    Sign in with Bitbucket Cloud using the provider/bitbucket package.

    cd examples/oauth-bitbucket && go run .
    View on GitHub
  • A host-owned OAuth consent page that returns a one-hour grant with one scope unticked. Runs in memory with no network.

    go run ./examples/oauth-consent
    View on GitHub
  • oauth-facebook

    Sign in with Facebook using the provider/facebook package.

    cd examples/oauth-facebook && go run .
    View on GitHub
  • oauth-gitlab

    Sign in with GitLab using the provider/gitlab package.

    cd examples/oauth-gitlab && go run .
    View on GitHub
  • oauth-linkedin

    Sign in with LinkedIn using the provider/linkedin package.

    cd examples/oauth-linkedin && go run .
    View on GitHub
  • oauth-multi-provider

    A single theAuth instance wired up with all four OAuth providers shipped by the library: GitHub, Google, Microsoft, and Discord.

    cd examples/oauth-multi-provider && go run .
    View on GitHub
  • oauth-slack

    Sign in with Slack using the provider/slack package.

    cd examples/oauth-slack && go run .
    View on GitHub
  • oauth-twitch

    Sign in with Twitch using the provider/twitch package.

    cd examples/oauth-twitch && go run .
    View on GitHub
  • oauth-x

    Sign in with X (formerly Twitter) using the provider/x package.

    cd examples/oauth-x && go run .
    View on GitHub
  • observability-otel

    Reference adapter bridging theauth.Tracer to go.opentelemetry.io/otel.

    cd examples/observability-otel && go run .
    View on GitHub
  • observability-prom

    A reference adapter that bridges theauth.Metrics to the Prometheus client library.

    cd examples/observability-prom && go run .
    View on GitHub
  • policy-shrink

    Records an agent's tool decisions, proposes a smaller policy from what it actually used, and replays the decisions against it.

    go run ./examples/policy-shrink
    View on GitHub
  • single-binary-sqlite

    A complete app with auth in one static Go binary and one SQLite file: no database server, no cgo, no framework.

    cd examples/single-binary-sqlite && go run .
    View on GitHub
  • stdlib-app

    theauth-go behind a plain net/http ServeMux with Go 1.22 pattern routing, no router dependency.

    cd examples/stdlib-app && go run .
    View on GitHub
  • taint-guard-go

    A taint-aware tool guard (policy/toolguard with policy.TaintRule) that blocks a tool call when untrusted input reached its arguments.

    go run ./examples/taint-guard-go
    View on GitHub
  • token-vault-smoke

    Checks a token vault provider preset against the real provider with your own test credentials. Never runs in CI.

    go run ./examples/token-vault-smoke
    View on GitHub
  • token-vault

    An agent gets a short-lived access token for a connected provider on a user's behalf without holding the refresh token. A stub provider runs in process.

    go run ./examples/token-vault
    View on GitHub
  • totp-stepup

    Password sign-in with a TOTP second factor: sign up, enroll TOTP, sign out and sign back in through the pending-second-factor session.

    go run ./examples/totp-stepup
    View on GitHub
  • webauthn-passkey

    Passkey registration and discoverable login with Config.WebAuthn on a single page.

    go run ./examples/webauthn-passkey
    View on GitHub

TypeScript examples

Packages in this list are pnpm workspace members, so install once at the repository root and filter by path. Single-file demos list their setup steps in their README. See the TypeScript page for the npm packages.

  • admin-approval-flow

    An admin MCP server proposes a revoke_delegation, self-approval is refused with 403, and a second admin approves it.

    pnpm install && pnpm --filter ./examples/admin-approval-flow start
    View on GitHub
  • agent-accountability

    A runnable, in-memory demo of the accountability loop for an AI agent: who it is, what it may do, who said yes, and what the record shows.

    pnpm install && pnpm --filter ./examples/agent-accountability start
    View on GitHub
  • agent-delegation-e2e

    One script: a user delegates a scoped token to an agent, an MCP server verifies it, and the agent is denied once the delegation is revoked.

    pnpm install && pnpm --filter ./examples/agent-delegation-e2e start
    View on GitHub
  • audit-receipts

    Sign a checkpoint of the audit log, mint a receipt that reveals only a few fields, and verify it from the receipt JSON and a public key.

    npx tsx index.ts (setup steps in the README)
    View on GitHub
  • basic-agent

    Minimal example showing agent creation, permission scoping, and authorization with theAuth.

    pnpm install && pnpm --filter ./examples/basic-agent start
    View on GitHub
  • browser-extension

    A Manifest V3 browser extension that signs in with OAuth 2.1 and PKCE through @glinr/theauth-extension.

    Load examples/browser-extension as an unpacked extension
    View on GitHub
  • cloudflare-workers

    theAuth running on Cloudflare Workers with D1 as the database.

    pnpm install && pnpm --filter ./examples/cloudflare-workers dev
    View on GitHub
  • hono-server

    Full auth server using theAuth with the Hono adapter.

    pnpm install && pnpm --filter ./examples/hono-server start
    View on GitHub
  • mcp-revocation-demo

    Revoke a delegation and the agent's MCP token stops working on the next request, even though the signed token has not expired.

    Load examples/mcp-revocation-demo as an unpacked extension
    View on GitHub
  • mcp-server

    theAuth as an MCP OAuth 2.1 authorization server.

    pnpm install && pnpm --filter ./examples/mcp-server start
    View on GitHub
  • migrate-from-auth0

    Runnable companion to the Auth0 migration guide: a machine-to-machine client rebuilt as a scoped agent with rotation and policy constraints.

    pnpm install && pnpm --filter ./examples/migrate-from-auth0 start
    View on GitHub
  • migrate-from-better-auth-agent-plugin

    Runnable companion to the Better Auth agent plugin migration guide: agent identities, multi-hop delegation chains and cascading revocation.

    pnpm install && pnpm --filter ./examples/migrate-from-better-auth-agent-plugin start
    View on GitHub
  • nextjs-app

    Full-stack Next.js 15 app with theAuth authentication.

    pnpm install && pnpm --filter ./examples/nextjs-app dev
    View on GitHub
  • nextjs-demo

    A working demo of theAuth auth and agent features built with Next.js App Router.

    pnpm install && pnpm --filter ./examples/nextjs-demo dev
    View on GitHub
  • openai-agents-guard

    A runnable demo of guardTool in front of OpenAI Agents SDK tools.

    npx tsx index.ts (setup steps in the README)
    View on GitHub
  • policy-shrink

    Records an agent's tool decisions, proposes a smaller policy from what it actually used, and replays the decisions against it.

    npx tsx index.ts (setup steps in the README)
    View on GitHub
  • scim-okta

    A minimal SCIM 2.0 server you can point Okta at.

    pnpm install && pnpm --filter ./examples/scim-okta start
    View on GitHub
  • taint-guard

    A runnable demo of provenance labels with guardTool.

    npx tsx index.ts (setup steps in the README)
    View on GitHub
  • vercel-ai-sdk-guard

    A runnable demo of guardTool in front of Vercel AI SDK tools.

    npx tsx index.ts (setup steps in the README)
    View on GitHub

Get started

Give your first agent an identity.

Install the package, create an agent with scoped permissions, and read its first audit record. The core runs on Postgres, SQLite, MySQL or D1, and the Go module needs a single go get.

  • npm install @glinr/theauth
  • go get github.com/glincker/theauth-go/v2
Or skip hosting with theAuth Cloud