File contents OAuth Implementation
Table of Contents
Overview
Implement industry-standard OAuth 2.0 and OpenID Connect authentication flows with JWT tokens, refresh tokens, and secure session management.
When to Use
User authentication systems
Third-party API integration
Single Sign-On (SSO) implementation
Mobile app authentication
Microservices security
Social login integration
Quick Start
Minimal working example:
// oauth-server.js - Complete OAuth 2.0 implementation
const express = require("express");
const jwt = require("jsonwebtoken");
const crypto = require("crypto");
const bcrypt = require("bcrypt");
class OAuthServer {
constructor() {
this.app = express();
this.clients = new Map();
this.authorizationCodes = new Map();
this.refreshTokens = new Map();
this.accessTokens = new Map();
// JWT signing keys
this.privateKey = process.env.JWT_PRIVATE_KEY;
this.publicKey = process.env.JWT_PUBLIC_KEY;
this.setupRoutes();
}
// Register OAuth client
registerClient(clientId, clientSecret, redirectUris) {
this.clients.set(clientId, {
clientSecret: bcrypt.hashSync(clientSecret, 10),
// ... (see reference guides for full implementation)
Reference Guides
Detailed implementations in the references/ directory:
Guide
Contents
Node.js OAuth 2.0 Server
Node.js OAuth 2.0 Server
Python OpenID Connect Implementation
Python OpenID Connect Implementation
Java Spring Security OAuth
Java Spring Security OAuth
Best Practices
✅ DO
Use PKCE for public clients
Implement token rotation
Store tokens securely
Use HTTPS everywhere
Validate redirect URIs
Implement rate limiting
Use short-lived access tokens
Log authentication events
❌ DON'T
Store tokens in localStorage
Use implicit flow
Skip state parameter
Expose client secrets
Allow open redirects
Use weak signing keys
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1 --- 2 name: aj-geddes-useful-ai-prompts-oauth-implementation 3 description: OAuth Implementation 4 --- 5 6 # OAuth Implementation 7 8 ## Table of Contents 9 10 - [Overview](#overview) 11 - [When to Use](#when-to-use) 12 - [Quick Start](#quick-start) 13 - [Reference Guides](#reference-guides) 14 - [Best Practices](#best-practices) 15 16 ## Overview 17 18 Implement industry-standard OAuth 2.0 and OpenID Connect authentication flows with JWT tokens, refresh tokens, and secure session management. 19 20 ## When to Use 21 22 - User authentication systems 23 - Third-party API integration 24 - Single Sign-On (SSO) implementation 25 - Mobile app authentication 26 - Microservices security 27 - Social login integration 28 29 ## Quick Start 30 31 Minimal working example: 32 33 ```javascript 34 // oauth-server.js - Complete OAuth 2.0 implementation 35 const express = require("express"); 36 const jwt = require("jsonwebtoken"); 37 const crypto = require("crypto"); 38 const bcrypt = require("bcrypt"); 39 40 class OAuthServer { 41 constructor() { 42 this.app = express(); 43 this.clients = new Map(); 44 this.authorizationCodes = new Map(); 45 this.refreshTokens = new Map(); 46 this.accessTokens = new Map(); 47 48 // JWT signing keys 49 this.privateKey = process.env.JWT_PRIVATE_KEY; 50 this.publicKey = process.env.JWT_PUBLIC_KEY; 51 52 this.setupRoutes(); 53 } 54 55 // Register OAuth client 56 registerClient(clientId, clientSecret, redirectUris) { 57 this.clients.set(clientId, { 58 clientSecret: bcrypt.hashSync(clientSecret, 10), 59 // ... (see reference guides for full implementation) 60 ``` 61 62 ## Reference Guides 63 64 Detailed implementations in the `references/` directory: 65 66 | Guide | Contents | 67 |---|---| 68 | [Node.js OAuth 2.0 Server](references/nodejs-oauth-20-server.md) | Node.js OAuth 2.0 Server | 69 | [Python OpenID Connect Implementation](references/python-openid-connect-implementation.md) | Python OpenID Connect Implementation | 70 | [Java Spring Security OAuth](references/java-spring-security-oauth.md) | Java Spring Security OAuth | 71 72 ## Best Practices 73 74 ### ✅ DO 75 76 - Use PKCE for public clients 77 - Implement token rotation 78 - Store tokens securely 79 - Use HTTPS everywhere 80 - Validate redirect URIs 81 - Implement rate limiting 82 - Use short-lived access tokens 83 - Log authentication events 84 85 ### ❌ DON'T 86 87 - Store tokens in localStorage 88 - Use implicit flow 89 - Skip state parameter 90 - Expose client secrets 91 - Allow open redirects 92 - Use weak signing keys 93 94 --- 95 > Converted and distributed by [TomeVault](https://tomevault.io/claim/aj-geddes) — claim your Tome and manage your conversions. 96 <!-- tomevault:4.0:skill_md:2026-04-11 -->
tomevault-io/skills-registry/tree/main/aj-geddes--useful-ai-prompts--oauth-implementation commit 21ede26d6f
Frequently asked questions How do I install the Aj Geddes Useful AI Prompts OAUTH Implementation skill? Run npx skillmds@latest add tomevault-io/aj-geddes-useful-ai-prompts-oauth-implementation in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Aj Geddes Useful AI Prompts OAUTH Implementation skill do? OAuth Implementation It is listed under Integrations & APIs on SkillMD.
Is Aj Geddes Useful AI Prompts OAUTH Implementation safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Aj Geddes Useful AI Prompts OAUTH Implementation? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Aj Geddes Useful AI Prompts OAUTH Implementation free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Aj Geddes Useful AI Prompts OAUTH Implementation? tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.