Overview
InsForge can function as an OAuth 2.0 identity provider, allowing third-party applications to authenticate users with “Sign in with InsForge”. This enables developers building on your platform to leverage InsForge’s authentication system without managing their own user credentials.Use Cases
Developer Platforms
Enable third-party developers to build integrations with “Sign in with InsForge” while you maintain control over user data access.
AI Agents & MCP
Authenticate AI agents and LLM tools via Model Context Protocol with OAuth-based authorization.
Partner Applications
Allow partner applications to authenticate users against your InsForge project without sharing credentials.
CLI & Desktop Apps
Issue OAuth tokens to command-line tools and desktop applications that need API access.
OAuth 2.0 Flow
InsForge implements the Authorization Code flow with PKCE (Proof Key for Code Exchange), the most secure OAuth flow for both web and native applications.Getting Started
1
Register Your Application
Contact InsForge to register your application as an OAuth client. You’ll receive:
- Client ID: Public identifier for your application
- Client Secret: Confidential key for server-side token exchange
- Allowed Redirect URIs: URLs where users can be redirected after authorization
2
Configure Scopes
Define which permissions your application needs:
3
Implement Authorization Flow
Integrate the OAuth flow into your application using the endpoints below.
Endpoints
Authorization Endpoint
Redirect users to this endpoint to initiate the OAuth flow.
Example:
Token Endpoint
Exchange the authorization code for access and refresh tokens.Refresh Token
Exchange a refresh token for a new access token.User Profile Endpoint
Retrieve the authenticated user’s profile information.Implementation Guide
Generate PKCE Parameters
PKCE adds an extra layer of security by ensuring the application that started the flow is the same one completing it.- Node.js
- Python
- Browser (Web Crypto)
Complete Server-Side Example
Here’s a complete Express.js implementation. First, create a.env file with your credentials:
Generate a secure session secret using:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Popup Mode for SPAs
For single-page applications, you can open the OAuth flow in a popup window:Security Considerations
Always Use PKCE
PKCE is mandatory for all OAuth flows. It prevents authorization code interception attacks.
Validate State
Always verify the state parameter in callbacks to prevent CSRF attacks.
Secure Token Storage
Store access tokens in memory or secure httpOnly cookies. Never expose tokens in URLs or localStorage.
Use HTTPS
All OAuth endpoints require HTTPS in production. Never transmit tokens over unencrypted connections.
Short Token Expiry
Access tokens expire in 1 hour. Use refresh tokens to obtain new access tokens without re-authentication.
Scope Minimization
Request only the scopes your application needs. Users are more likely to approve limited permissions.
Token Claims
Access tokens are JWTs containing the following claims:Error Handling
Authorization Errors
If authorization fails, users are redirected to yourredirect_uri with error parameters:
Token Errors
Token endpoint errors return JSON:Rate Limits
OAuth endpoints are rate-limited to prevent abuse:Resources
OAuth Example Repository
Complete working example showing how to integrate “Sign in with InsForge” into your application.