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
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.
View on GitHubgo run ./examples/agent-policyagent-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.
View on GitHubgo run ./examples/agent-tool-guardaudit-receipts-go
A signed audit checkpoint, a portable receipt and a consistency proof over a chained SQLite audit log.
View on GitHubcd examples/audit-receipts-go && go run .chi-app
Minimal runnable example demonstrating magic-link auth.
View on GitHubcd examples/chi-app && go run .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.
View on GitHubgo run ./examples/cli-device-logincli-login
A host CLI that authenticates against a theauth-go server with RFC 8628 device login, using the clientauth package.
View on GitHubgo run ./examples/cli-logindoctor-admin
Serves /healthz publicly and a root-only /admin/security page that renders the report from Doctor, the configuration auditor.
View on GitHubgo run ./examples/doctor-adminecho-app
theauth-go behind an Echo v4 router, mounted on a chi subrouter and wrapped with echo.WrapHandler.
View on GitHubcd examples/echo-app && go run .gin-app
theauth-go inside a Gin router, mounted on a chi subrouter and wrapped with gin.WrapH.
View on GitHubcd examples/gin-app && go run .github-actions-oidc
GitHub Actions OIDC login, end to end and offline.
View on GitHubgo run ./examples/github-actions-oidchooks
Wires every Config.LifecycleHooks callback to a log line so you can see when each one fires.
View on GitHubgo run ./examples/hooksmcp-server
A small MCP resource server built on the separate mcpresource module.
View on GitHubcd examples/mcp-server && go run .oauth-apple
Sign in with Apple using the provider/apple package.
View on GitHubcd examples/oauth-apple && go run .oauth-bitbucket
Sign in with Bitbucket Cloud using the provider/bitbucket package.
View on GitHubcd examples/oauth-bitbucket && go run .oauth-consent
A host-owned OAuth consent page that returns a one-hour grant with one scope unticked. Runs in memory with no network.
View on GitHubgo run ./examples/oauth-consentoauth-facebook
Sign in with Facebook using the provider/facebook package.
View on GitHubcd examples/oauth-facebook && go run .oauth-gitlab
Sign in with GitLab using the provider/gitlab package.
View on GitHubcd examples/oauth-gitlab && go run .oauth-linkedin
Sign in with LinkedIn using the provider/linkedin package.
View on GitHubcd examples/oauth-linkedin && go run .oauth-multi-provider
A single theAuth instance wired up with all four OAuth providers shipped by the library: GitHub, Google, Microsoft, and Discord.
View on GitHubcd examples/oauth-multi-provider && go run .oauth-slack
Sign in with Slack using the provider/slack package.
View on GitHubcd examples/oauth-slack && go run .oauth-twitch
Sign in with Twitch using the provider/twitch package.
View on GitHubcd examples/oauth-twitch && go run .oauth-x
Sign in with X (formerly Twitter) using the provider/x package.
View on GitHubcd examples/oauth-x && go run .observability-otel
Reference adapter bridging theauth.Tracer to go.opentelemetry.io/otel.
View on GitHubcd examples/observability-otel && go run .observability-prom
A reference adapter that bridges theauth.Metrics to the Prometheus client library.
View on GitHubcd examples/observability-prom && go run .policy-shrink
Records an agent's tool decisions, proposes a smaller policy from what it actually used, and replays the decisions against it.
View on GitHubgo run ./examples/policy-shrinksingle-binary-sqlite
A complete app with auth in one static Go binary and one SQLite file: no database server, no cgo, no framework.
View on GitHubcd examples/single-binary-sqlite && go run .stdlib-app
theauth-go behind a plain net/http ServeMux with Go 1.22 pattern routing, no router dependency.
View on GitHubcd examples/stdlib-app && go run .taint-guard-go
A taint-aware tool guard (policy/toolguard with policy.TaintRule) that blocks a tool call when untrusted input reached its arguments.
View on GitHubgo run ./examples/taint-guard-gotoken-vault-smoke
Checks a token vault provider preset against the real provider with your own test credentials. Never runs in CI.
View on GitHubgo run ./examples/token-vault-smoketoken-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.
View on GitHubgo run ./examples/token-vaulttotp-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.
View on GitHubgo run ./examples/totp-stepupwebauthn-passkey
Passkey registration and discoverable login with Config.WebAuthn on a single page.
View on GitHubgo run ./examples/webauthn-passkey
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.
View on GitHubpnpm install && pnpm --filter ./examples/admin-approval-flow startagent-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.
View on GitHubpnpm install && pnpm --filter ./examples/agent-accountability startagent-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.
View on GitHubpnpm install && pnpm --filter ./examples/agent-delegation-e2e startaudit-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.
View on GitHubnpx tsx index.ts (setup steps in the README)basic-agent
Minimal example showing agent creation, permission scoping, and authorization with theAuth.
View on GitHubpnpm install && pnpm --filter ./examples/basic-agent startbrowser-extension
A Manifest V3 browser extension that signs in with OAuth 2.1 and PKCE through @glinr/theauth-extension.
View on GitHubLoad examples/browser-extension as an unpacked extensioncloudflare-workers
theAuth running on Cloudflare Workers with D1 as the database.
View on GitHubpnpm install && pnpm --filter ./examples/cloudflare-workers devhono-server
Full auth server using theAuth with the Hono adapter.
View on GitHubpnpm install && pnpm --filter ./examples/hono-server startmcp-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.
View on GitHubLoad examples/mcp-revocation-demo as an unpacked extensionmcp-server
theAuth as an MCP OAuth 2.1 authorization server.
View on GitHubpnpm install && pnpm --filter ./examples/mcp-server startmigrate-from-auth0
Runnable companion to the Auth0 migration guide: a machine-to-machine client rebuilt as a scoped agent with rotation and policy constraints.
View on GitHubpnpm install && pnpm --filter ./examples/migrate-from-auth0 startmigrate-from-better-auth-agent-plugin
Runnable companion to the Better Auth agent plugin migration guide: agent identities, multi-hop delegation chains and cascading revocation.
View on GitHubpnpm install && pnpm --filter ./examples/migrate-from-better-auth-agent-plugin startnextjs-app
Full-stack Next.js 15 app with theAuth authentication.
View on GitHubpnpm install && pnpm --filter ./examples/nextjs-app devnextjs-demo
A working demo of theAuth auth and agent features built with Next.js App Router.
View on GitHubpnpm install && pnpm --filter ./examples/nextjs-demo devopenai-agents-guard
A runnable demo of guardTool in front of OpenAI Agents SDK tools.
View on GitHubnpx tsx index.ts (setup steps in the README)policy-shrink
Records an agent's tool decisions, proposes a smaller policy from what it actually used, and replays the decisions against it.
View on GitHubnpx tsx index.ts (setup steps in the README)scim-okta
A minimal SCIM 2.0 server you can point Okta at.
View on GitHubpnpm install && pnpm --filter ./examples/scim-okta starttaint-guard
A runnable demo of provenance labels with guardTool.
View on GitHubnpx tsx index.ts (setup steps in the README)vercel-ai-sdk-guard
A runnable demo of guardTool in front of Vercel AI SDK tools.
View on GitHubnpx tsx index.ts (setup steps in the README)
Longer walkthroughs
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/theauthgo get github.com/glincker/theauth-go/v2