Skip to main content
skill CX Codex

oauth-implementation · secondsky — Claude Code skill: what it does, how to install

Guides OAuth 2.0 and OpenID Connect setup across web, mobile, and backend services while enforcing token rotation and PKCE.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add secondsky/claude-skills --skill oauth-implementation -a claude-code
Open on GitHub

What oauth-implementation does

The skill provides architectural patterns and code samples for OAuth 2.0 and OpenID Connect. It covers Authorization Code flow, PKCE for public clients like SPAs or mobile apps, Client Credentials for backend microservices, and session renewal mechanisms.

Node.js and Express examples detail state parameter verification during login, callback handling, and crypto-based PKCE challenge generation. Additional reference material covers Python Flask with Authlib, OpenID Connect discovery endpoints, JWKS, and Java Spring Security OAuth2 configurations.

Security rules are explicit: access tokens must expire within 15 minutes, cookies must carry the HttpOnly flag, and storing tokens in localStorage or relying on the implicit flow is forbidden.

What it helps with

  • build an Authorization Code flow with strict state validation
  • generate PKCE verifiers and SHA-256 challenges for public clients
  • set up service-to-service authorization via Client Credentials
  • configure token rotation and short-lived access tokens

Example prompts for the agent

  • Write Express routes for /auth/login and /auth/callback with state check.
  • Generate a Node.js PKCE helper using crypto.randomBytes and sha256.
  • Show how to structure token refresh rotation with 15-minute access token lifespans.

How to install oauth-implementation

1Skills CLI (Vercel)

npx skills add secondsky/claude-skills --skill oauth-implementation -a claude-code

2Manually: put the files in place

~/.claude/skills/oauth-implementation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/oauth-implementation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about oauth-implementation

How to install oauth-implementation in Claude Code?

Run npx skills add secondsky/claude-skills --skill oauth-implementation -a claude-code. It installs the skill file directly into your environment.

What does the oauth-implementation skill do?

It supplies templates and security constraints for OAuth 2.0 and OIDC integrations, SSO setups, and debugging authorization errors.

What security constraints does this skill enforce?

It mandates HTTPS, exact redirect URI matching, HttpOnly cookie storage, and 15-minute token lifespans. Storing credentials in localStorage and using the implicit flow are disallowed.

Source text

SKILL.md · MIT
---
name: oauth-implementation
description: OAuth 2.0 and OpenID Connect authentication with secure flows. Use for third-party integrations, SSO systems, token-based API access, or encountering authorization code flow, PKCE, token refresh, scope management errors.
license: MIT
---

# OAuth Implementation

Implement OAuth 2.0 and OpenID Connect for secure authentication.

## OAuth 2.0 Flows

| Flow | Use Case |
|------|----------|
| Authorization Code | Web apps (most secure) |
| Authorization Code + PKCE | SPAs, mobile apps |
| Client Credentials | Service-to-service |
| Refresh Token | Session renewal |

## Authorization Code Flow (Express)

```javascript
const express = require('express');
const jwt = require('jsonwebtoken');

// Step 1: Redirect to authorization
app.get('/auth/login', (req, res) => {
  const state = crypto.randomBytes(16).toString('hex');
  req.session.oauthState = state;

  const params = new URLSearchParams({
    client_id: process.env.CLIENT_ID,
    redirect_uri: process.env.REDIRECT_URI,
    response_type: 'code',
    scope: 'openid profile email',
    state
  });

  res.redirect(`${PROVIDER_URL}/authorize?${params}`);
});

// Step 2: Handle callback
app.get('/auth/callback', async (req, res) => {
  if (req.query.state !== req.session.oauthState) {
    return res.status(400).json({ error: 'Invalid state' });
  }

  const tokenResponse = await fetch(`${PROVIDER_URL}/token`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams({
      grant_type: 'authorization_code',
      code: req.query.code,
      redirect_uri: process.env.REDIRECT_URI,
      client_id: process.env.CLIENT_ID,
      client_secret: process.env.CLIENT_SECRET
    })
  });

  const tokens = await tokenResponse.json();
  // Store tokens securely and create session
});
```

## PKCE for Public Clients

```javascript
function generatePKCE() {
  const verifier = crypto.randomBytes(32).toString('base64url');
  const challenge = crypto
    .createHash('sha256')
    .update(verifier)
    .digest('base64url');
  return { verifier, challenge };
}
```

## Security Requirements

- Always use HTTPS
- Validate redirect URIs strictly
- Use PKCE for public clients
- Store tokens in HttpOnly cookies
- Implement token rotation
- Use short-lived access tokens (15 min)

## Additional Implementations

See [references/python-java.md](references/python-java.md) for:
- Python Flask with Authlib OIDC provider
- OpenID Connect discovery and JWKS endpoints
- Java Spring Security OAuth2 server
- Token introspection and revocation

## Never Do

- Store tokens in localStorage
- Use implicit flow
- Skip state parameter validation
- Expose client secrets in frontend
- Use long-lived access tokens

© secondsky · MIT · secondsky/claude-skills

Similar skills

All skills for Security →

oauth-implementation by other authors comes first.

oauth-implementation aj-geddes Guides the setup of OAuth 2.0, OpenID Connect, JWT tokens, and SSO in web and mobile apps. Useful when configuring social logins or securing backend APIs. CX Codex +1 553installs oauth-implementation Mindrally Guides coding agents through OAuth 2.0 and 2.1 setup with PKCE, state checks, and token rotation. Built to prevent insecure grants like implicit flow. CX Codex +1 719installs git-guardrails-claude-code Matt Pocock This skill adds a Claude Code hook that stops risky Git commands before they run. Use it when an agent must not push or discard working-tree changes. 499,069installs ponytail-review DietrichGebert ponytail-review reviews a change beyond the diff, checking connected code, bugs, risks, load, tests, speed, and unnecessary code. Use it for PRs and commits. CX Codex +1 57,000installs ponytail-audit DietrichGebert It audits a repository and ranks bugs, risks, and redundant code in a one-shot report. Use it when you need a review without code changes. CX Codex +1 45,400installs security-audit cloudflare Reviews codebases and APIs for vulnerabilities using safe sandboxing. Fits pre-release security reviews, pen-test triage, and architecture checks. CX Codex +1 54,800installs security-and-hardening addyosmani Guides threat modeling and security checks for code that handles user input, authentication, sessions, or external services. Use it when building a feature that accepts untrusted data or reviewing code before release. CX Codex +1 70,200installs supabase official supabase Guides the agent through database configuration and strict RLS policies in Supabase. CX Codex GP ChatGPT 8installs

From the same set116

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor