🚀 OAuth Features
OAuth features provide complete, pre-composed functionality for OAuth authentication flows. These features combine schemas and routes to create ready-to-use endpoints for OAuth initiation and callback processing.
🎯 Overview
OAuth features are designed to:
- Provide complete OAuth workflows for provider-based login
- Combine schemas with routes for validated request processing
- Integrate with drivers/blocks to orchestrate the full OAuth flow
📋 Feature Structure
Each OAuth feature follows a consistent composition pattern:
- Schema: Validates input data and parameters
- Route: Provides HTTP endpoint with block composition
- Composition: Combines schema and route using
compose
🔧 Available OAuth Features
googleOAuthFeature
Google OAuth authentication feature with schema validation and routing.
Purpose: Starts the Google OAuth flow and redirects to provider consent.
Composition:
- Schema:
googleOauthSchema— validates query parameters (fp,purpose,redirectUrl,typeId) and enforces empty request body - Route:
googleOAuthRoute— handles Google OAuth initiation
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database (handlers may need dataStores):
app.use('/api', defService(partial(features.googleOAuthFeature, [{ dataStores: db }])));
API Endpoint: GET /api/auth/oauth/google
googleOAuthCallbackFeature
Google OAuth callback feature with routing for callback processing.
Purpose: Completes the OAuth flow by authenticating the provider callback, verifying login state, and performing final redirect.
Composition:
- Route:
googleOAuthCallbackRoute— handles Google OAuth callback verification and user processing
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database (handlers may need dataStores):
app.use('/api', defService(partial(features.googleOAuthCallbackFeature, [{ dataStores: db }])));
API Endpoint: GET /api/auth/oauth/google/callback
twitterOAuthFeature
Twitter OAuth authentication feature with schema validation and routing.
Purpose: Starts the Twitter OAuth flow and redirects to provider consent.
Composition:
- Schema:
twitterOauthSchema— validates query parameters (purpose,redirectUrl,typeId) and enforces empty request body - Route:
twitterOAuthRoute— handles Twitter OAuth initiation
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database (handlers may need dataStores):
app.use('/api', defService(partial(features.twitterOAuthFeature, [{ dataStores: db }])));
API Endpoint: GET /api/auth/oauth/twitter
twitterOAuthCallbackFeature
Twitter OAuth callback feature with routing for callback processing.
Purpose: Completes the OAuth flow by authenticating the provider callback, verifying user, and performing final redirect.
Composition:
- Route:
twitterOAuthCallbackRoute— handles Twitter OAuth callback verification and user processing
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database (handlers may need dataStores):
app.use('/api', defService(partial(features.twitterOAuthCallbackFeature, [{ dataStores: db }])));
API Endpoint: GET /api/auth/oauth/twitter/callback
lineOAuthFeature
LINE OAuth authentication feature with schema validation and routing.
Purpose: Starts the LINE OAuth flow and redirects to provider consent.
Composition:
- Schema:
lineOauthSchema— validates query parameters (fp,purpose,redirectUrl,typeId) and enforces empty request body - Route:
lineOAuthRoute— handles LINE OAuth initiation
Usage:
import { features } from '@nodeblocks/backend-sdk';
// Direct usage:
app.use('/api', defService(features.lineOAuthFeature));
// With database (handlers may need dataStores):
app.use('/api', defService(partial(features.lineOAuthFeature, [{ dataStores: db }])));
API Endpoint: GET /api/auth/oauth/line
Query Parameters:
fp: string(required) — Device fingerprint identifierpurpose: 'oauth-login' | 'oauth-signup'(required) — OAuth flow purposeredirectUrl: string(required) — Client redirect destinationtypeId: string(required) — Identity type identifier for signup
Response: Redirects to LINE OAuth authorization page (302)
Key Features:
- Schema validation for all query parameters
- One-time token generation for state management
- Integration with LINE OAuth driver
- Supports both login and signup flows
lineOAuthCallbackFeature
LINE OAuth callback feature with routing for callback processing.
Purpose: Completes the OAuth flow by authenticating the provider callback, verifying login state, and performing final redirect.
Composition:
- Route:
lineOAuthCallbackRoute— handles LINE OAuth callback verification and user processing
Usage:
import { features } from '@nodeblocks/backend-sdk';
// Direct usage:
app.use('/api', defService(features.lineOAuthCallbackFeature));
// With database (handlers may need dataStores):
app.use('/api', defService(partial(features.lineOAuthCallbackFeature, [{ dataStores: db }])));
API Endpoint: GET /api/auth/oauth/line/callback
Response: Redirects to client application with authentication token
Handler Process:
- Authenticates LINE OAuth callback
- Extracts and verifies login state
- Finds or creates user identity
- Generates authentication token
- Redirects to client application
Error Handling:
400- Invalid input or missing fields404- Identity not found (for login flows)500- Database errors or OAuth failures
Key Features:
- Complete OAuth callback processing
- Identity resolution or creation
- Token generation and secure redirect
- Comprehensive error handling