Skip to content
secondsky avatar

Api Authentication

Secure API authentication guide covering JWT, OAuth 2.0, and API keys with token handling and security headers.

CCM score
53 of 100
skills.sh installs
563
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers authentication methods compared by use case and security level: JWT, OAuth 2.0, API keys, and sessions
  • Includes a Node.js JWT example with access and refresh token generation and a Bearer header validation middleware
  • Enforces security requirements such as HttpOnly cookies over localStorage, bcrypt password hashing, and no tokens in URLs
  • Provides HTTP security headers and a Flask reference covering role-based access, Google OAuth via Authlib, and hashed API keys

Install

$ npx -y skills add secondsky/claude-skills --skill api-authentication -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

API Authentication

Implement secure authentication mechanisms for APIs using modern standards and best practices.

Authentication Methods

MethodUse CaseSecurity Level
JWTStateless auth, SPAsHigh
OAuth 2.0Third-party integrationHigh
API KeysService-to-serviceMedium
SessionTraditional web appsHigh

JWT Implementation (Node.js)

const jwt = require('jsonwebtoken');

const generateTokens = (user) => ({
  accessToken: jwt.sign(
    { userId: user.id, role: user.role },
    process.env.JWT_SECRET,
    { expiresIn: '15m' }
  ),
  refreshToken: jwt.sign(
    { userId: user.id, type: 'refresh' },
    process.env.REFRESH_SECRET,
    { expiresIn: '7d' }
  )
});

const authMiddleware = (req, res, next) => {
  const authHeader = req.headers.authorization;

  // Validate authorization header format
  if (!authHeader || !authHeader.startsWith('Bearer ')) {
    return res.status(401).json({ error: 'Malformed authorization header' });
  }

  const parts = authHeader.split(' ');
  if (parts.length !== 2) {
    return res.status(401).json({ error: 'Malformed authorization header' });
  }

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Security
First seen
Jun 3, 2026

Questions

What does the api-authentication skill do?

api-authentication teaches the agent to implement secure API authentication with JWT, OAuth 2.0 and API keys. It covers token generation and verification middleware, security headers, and common authentication mistakes to avoid.

Who should use the api-authentication skill?

api-authentication is for developers building authentication systems, third-party integrations, or service-to-service communication. It also helps when debugging token management, security header, or auth flow errors.

How do I install the api-authentication skill?

Run npx -y skills add secondsky/claude-skills --skill api-authentication -y in your project. After that, the api-authentication skill lets the agent follow its JWT, OAuth 2.0 and API key guidance when you work on authentication code.

Where does api-authentication sit in its category?

api-authentication is listed in the Backend & APIs category on Claude Marketplaces. Its own guidance covers JWT with HttpOnly cookies, bcrypt password hashing and rate limiting on auth endpoints, plus Flask and Google OAuth examples in a reference file.

More from secondsky/claude-skills

All 116

Similar to Api Authentication

More Backend & APIs