oauth2listed
Install: claude install-skill claude-dev-suite/claude-dev-suite
# OAuth 2.0 Core Knowledge
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `oauth2` for comprehensive documentation.
## Authorization Code Flow (Recommended)
```
1. User clicks "Login with Google"
2. Redirect to provider:
GET https://accounts.google.com/oauth/authorize
?client_id=xxx
&redirect_uri=https://app.com/callback
&response_type=code
&scope=openid email profile
&state=random_state
3. User authorizes, provider redirects:
GET https://app.com/callback?code=xxx&state=random_state
4. Backend exchanges code for tokens:
POST https://oauth2.googleapis.com/token
client_id=xxx
client_secret=xxx
code=xxx
grant_type=authorization_code
redirect_uri=https://app.com/callback
5. Receive tokens:
{ "access_token": "...", "refresh_token": "...", "id_token": "..." }
```
## Implementation
```typescript
// Step 1: Generate auth URL
function getAuthUrl(): string {
const params = new URLSearchParams({
client_id: process.env.GOOGLE_CLIENT_ID,
redirect_uri: `${process.env.APP_URL}/callback`,
response_type: 'code',
scope: 'openid email profile',
state: generateRandomState(),
});
return `https://accounts.google.com/oauth/authorize?${params}`;
}
// Step 2: Handle callback
async function handleCallback(code: string) {
const tokens = await exchangeCodeForTokens(code);
const userInfo = await getUserInfo(tokens.access_token);
const user = await findOrCreateUser(userInfo);