aj-geddes avatar

Api Authentication

This covers the core authentication patterns you'll actually use: JWT tokens, OAuth 2.0, API keys, and session management. The references include working implementations in both Node.js and Python, with examples for login flows, token refresh, and middleware protection. It's opinionated about security basics like HttpOnly cookies, bcrypt for passwords, and HTTPS everywhere. The best practices section is genuinely helpful, calling out common mistakes like storing tokens in URLs or logging credentials. If you're building an API and need to lock it down properly, this gives you the patterns and code to start from rather than piecing together blog posts.

skills.sh installs
612
GitHub stars
379
last updated
Aug 21, 2026

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill api-authentication --agent claude-code

Installs into .claude/skills of the current project.

Files

API Authentication

Table of Contents

Overview

Implement comprehensive authentication strategies for APIs including JWT tokens, OAuth 2.0, API keys, and session management with proper security practices.

When to Use

  • Securing API endpoints
  • Implementing user login/logout flows
  • Managing access tokens and refresh tokens
  • Integrating OAuth 2.0 providers
  • Protecting sensitive data
  • Implementing API key authentication

Quick Start

Minimal working example:

// Node.js JWT Implementation
const express = require('express');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');

const app = express();
const SECRET_KEY = process.env.JWT_SECRET || 'your-secret-key';
const REFRESH_SECRET = process.env.REFRESH_SECRET || 'your-refresh-secret';

// User login endpoint
app.post('/api/auth/login', async (req, res) => {
  try {
    const { email, password } = req.body;

Sponsors

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Backend & APIs, Security, AI & Agent Building
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258
1yoanbernabeu avatarsupabase-audit-auth-signupyoanbernabeu/supabase-pentest-skillsTest if user signup is open and identify potential abuse vectors in the registration process.495skills.sh installs
2bobmatnyc avatarbetter-auth-authenticationbobmatnyc/claude-mpm-skillsBetter Auth authentication flows for TypeScript apps. Use when enabling email/password auth, configuring social providers, or implementing sign-up, sign-in, and398skills.sh installs
3secondsky avatarbun-websocket-serversecondsky/claude-skillsThis skill should be used when the user asks about "WebSocket in Bun", "real-time communication", "Bun.serve websocket", "ws server", "socket connections", "pub326skills.sh installs
4TryGhost avatarAdd Admin API EndpointTryGhost/GhostAdd a new endpoint or endpoints to Ghost's Admin API at `ghost/api/admin/**`.0skills.sh installs
5giuseppe-trisciuoglio avatarspring-boot-rest-api-standardsgiuseppe-trisciuoglio/developer-kitProvides REST API design standards and best practices for Spring Boot projects. Use when creating or reviewing REST endpoints, DTOs, error handling, pagination,4.3Kskills.sh installs
6giuseppe-trisciuoglio avatarunit-test-wiremock-rest-apigiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing external REST APIs using WireMock. Stubs API responses, verifies request details, simulates failures (timeouts, 4xx/5xx error3.9Kskills.sh installs