oauth
Implements OAuth 2.0/2.1 authorization flows in Fastify applications — configures authorization code with PKCE, client credentials, device flow, refresh token…
Skill by mcollina
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/mcollina-oauth
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/oauth
What's inside
- Skill name
oauth- Description
- Implements OAuth 2.0/2.1 authorization flows in Fastify applications — configures authorization code with PKCE, client credentials, device flow, refresh token rotation, JWT validation, and token introspection/revocation endpoints. Use when setting up authentication, authorization, login flows, access tokens, API security, or securing Fastify routes with OAuth; also applies when troubleshooting token validation errors, mismatched redirect URIs, CSRF issues, scope problems, or RFC 6749/6750/7636/8252/8628 compliance questions.
- License
- MIT
- Metadata
- tags: oauth, oauth2, security, authentication, authorization, jwt, fastify
- Instructions
- 181 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- tile.json
SKILL.md (first lines)
## When to use
Use this skill when you need to:
- Implement or debug an OAuth 2.0/2.1 flow in a Fastify application
- Validate tokens, configure PKCE, or set up refresh token rotation
- Secure Fastify routes and plugins with access-control middleware
- Resolve RFC compliance questions or identify security anti-patterns
---
## Step-by-step: Authorization Code + PKCE in Fastify
### 1. Install dependencies
```bash
npm install @fastify/oauth2 @fastify/cookie @fastify/session fastify-plugin
```
### 2. Register the OAuth plugin
```typescript
// plugins/oauth.ts
import fp from 'fastify-plugin'
import oauth2, { OAuth2Namespace } from '@fastify/oauth2'
import { FastifyInstance } from 'fastify'
export default fp(async function (fastify: FastifyInstance) {
fastify.register(oauth2, {
name: 'oauth2',
scope: ['openid', 'profile', 'email'],
credentials: {
client: {
id: process.env.CLIENT_ID!,
secret: process.env.CLIENT_SECRET!,
},
auth: {
authorizeHost: process.env.AUTH_SERVER!,
authorizePath: '/authorize',
tokenHost: process.env.AUTH_SERVER!,
tokenPath: '/token',
},
},
startRedirectPath: '/login',
callbackUri: process.env.CALLBACK_URI!,
pkce: 'S256', // RFC 7636 — always use for public clients
generateStateFunction: (req) => req.session.state = crypto.randomUUID(),
checkStateFunction: (req, callback) =>
req.query.state === req.session.state ? callback() : callback(new Error('State mismatch')),
})
})
```
**Validation checkpoint:** Confirm `callbackUri` exactly matches a registered redirect URI at the authorization server before proceeding (RFC 6749 §3.1.2).
### 3. Handle the callback and exchange the code
```typescript
// routes/auth.ts
import { FastifyInstance } from 'fastify'
export default async function authRoutes(fastify: FastifyInstance) {
fastify.get('/login/callback', async (request, reply) => {
// @fastify/oauth2 verifies state and exchanges code automatically
const tokenResponse = await fastify.oauth2.getAccessTokenFromAuthorizationCodeFlow(request)
// Store only what you need; never log the raw token
request.session.set('accessToken', tokenResponse.token.access_token)
request.session.set('refreshToken', tokenResponse.token.refresh_token)
return reply.redirect('/')
})
fastify.get('/logout', async (request, reply) => {
await request.session.destroy()
return reply.redirect('/')
})
}
```
### 4. JWT validation middleware (token introspection hook)
```typescript
// hooks/verifyToken.ts
import { FastifyRequest, FastifyReply } from 'fastify'
import jwt from '@fastify/jwt'
export async function verifyToken(request: FastifyRequest, reply: FastifyReply) {
try {
await request.jwtVerify()
// Validate required claims (RFC 7519)
const payload = request.user as Record<string, unknown>
const now = Math.floor(Date.now() / 1000)
if (typeof payload.exp === 'number' && payload.exp < now)
return reply.code(401).send({ error: 'token_expired' })
if (payload.iss !== process.env.EXPECTED_ISSUER)
return reply.code(401).send({ error: 'invalid_issuer' })
if (payload.aud !== process.env.EXPECTED_AUDIENCE)
return reply.code(401).send({ error: 'invalid_audience' })
} catch (err) {
return reply.code(401).send({ error: 'invalid_token', error_description: (err as Error).message })
}
}
```
**Validation checkpoints:**
- Verify `exp`, `iss`, `aud`, and `sub` on every request — never skip (RFC 7519 §4)
- Use `fastify.jwt.verify` (asymmetric RS256/ES256) rather than HS256 for tokens issued by a third-party server
### 5. Protecting routes
```typescript
// routes/api.ts
import { FastifyInstance } from 'fastify'
import { verifyToken } from '../hooks/verifyToken'From mcollina/skills, MIT.
More from mcollina/skills
- 0.830score
octocat
mcollina
Use this skill whenever the prompt contains any `github.com` URL, even if the user only pastes a link and gives no GitHub-specific keywords.
SkillAFreshness: A★ 2KClaude Code +9 - 0.784score
nodejs-core
mcollina
Contributes to and debugs Node.js core, including nodejs/node commit and PR tone, contribution workflows, native crashes, V8 performance, node-gyp builds…
SkillBFreshness: B★ 2KClaude Code +9 - 0.779score
fastify-best-practices
mcollina
Guides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript.
SkillBFreshness: B★ 2KClaude Code +9 - 0.652score
skill-optimizer
mcollina
Optimizes AI skills for activation, clarity, and cross-model reliability.
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
documentation
mcollina
Creates, structures, and reviews technical documentation following the Diátaxis framework (tutorials, how-to guides, reference, and explanation pages).
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
node
mcollina
Provides domain-specific best practices for Node.js development with TypeScript, covering type stripping, async patterns, error handling, streams, modules…
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
init
mcollina
Creates, updates, or optimizes an AGENTS.md file for a repository with minimal, high-signal instructions covering non-discoverable coding conventions, tooling…
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
snipgrapher
mcollina
Configures and uses snipgrapher to generate polished code snippet images, including syntax-highlighted PNGs, SVGs, and WebP exports with custom themes…
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
typescript-magician
mcollina
Designs complex generic types, refactors `any` types to strict alternatives, creates type guards and utility types, and resolves TypeScript compiler errors.
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
linting-neostandard-eslint9
mcollina
Configures ESLint v9 flat config and neostandard for JavaScript and TypeScript projects, including migrating from legacy `.eslintrc*` files or the `standard`…
SkillDFreshness: D★ 2KClaude Code +9 - 0.455score
AGENTS.md · mcollina/skills
mcollina
AGENTS.md from mcollina/skills: 72 lines covering What this repository is, High-level architecture, Common commands, Editing rules for this repo and more.
TemplateDFreshness: D★ 2KCodex +5
Compare and alternatives
Featured in
Signals
- Stars
- 1,959
- Forks
- 147
- Open issues
- 5
- Last commit (this folder)
- Mar 13, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/mcollina/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from mcollina
- 0.830score
octocat
mcollina
Use this skill whenever the prompt contains any `github.com` URL, even if the user only pastes a link and gives no GitHub-specific keywords.
SkillAFreshness: A★ 2KClaude Code +9 - 0.784score
nodejs-core
mcollina
Contributes to and debugs Node.js core, including nodejs/node commit and PR tone, contribution workflows, native crashes, V8 performance, node-gyp builds…
SkillBFreshness: B★ 2KClaude Code +9 - 0.779score
fastify-best-practices
mcollina
Guides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript.
SkillBFreshness: B★ 2KClaude Code +9 - 0.652score
skill-optimizer
mcollina
Optimizes AI skills for activation, clarity, and cross-model reliability.
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
documentation
mcollina
Creates, structures, and reviews technical documentation following the Diátaxis framework (tutorials, how-to guides, reference, and explanation pages).
SkillDFreshness: D★ 2KClaude Code +9 - 0.652score
node
mcollina
Provides domain-specific best practices for Node.js development with TypeScript, covering type stripping, async patterns, error handling, streams, modules…
SkillDFreshness: D★ 2KClaude Code +9
Cite this page
oauth skill. Agent Mart. https://agentmart.dev/skills/mcollina-oauth (last updated 2026-10-24)