๐ OAuth Feature Blocks
OAuth feature blocks 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 feature blocks 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