Supported Providers
SecondMe
Primary OAuth provider with extended profile features
GitHub
Developer-friendly authentication
Widely-used OAuth provider
Authentication Flows
1. Login Flow
The standard OAuth 2.0 authorization code flow for user authentication: Steps:- User initiates login
- App redirects to provider’s authorization URL with
stateparameter - Provider authenticates user and returns authorization code
- App exchanges code for access token
- App fetches user profile using access token
- Session is established with auth payload cookie
2. Account Binding Flow
Allows users to link multiple OAuth providers to a single account: Steps:- User requests to bind a provider account with
?flow=bindparameter - OAuth flow proceeds normally
- After receiving profile, system checks if provider account is already bound
- If available, creates/updates
AuthIdentityrecord linking to canonical user ID - Redirects to profile page with bind result
Security Features
State Validation
State Validation
Each OAuth flow generates a random 32-character hex string stored in httpOnly cookies. The state is validated on callback to prevent CSRF attacks.
Secure Cookies
Secure Cookies
Token Storage
Token Storage
Access tokens are:
- Stored in MongoDB
AuthIdentitycollection - Never exposed to client-side JavaScript
- Associated with provider account ID and canonical user ID
Conflict Detection
Conflict Detection
During account binding, the system prevents:
- Binding a provider account already linked to another user
- Duplicate identity records
- Unauthorized identity takeover
Provider Details
SecondMe Provider
Authorization URL:https://go.second.me/oauth/
Token Endpoint: https://app.mindos.com/gate/lab/api/oauth/token/code
User Info Endpoint: https://app.mindos.com/gate/lab/api/secondme/user/info
Scopes:
user.info- Basic user informationuser.info.shades- User’s shade personasuser.info.softmemory- User’s soft memory traitschat- Chat capabilitiesnote.add- Note creationvoice- Voice features
id(userId)nameemailavatarbio(selfIntroduction)shades(optional)softMemory(optional)
GitHub Provider
Authorization URL:https://github.com/login/oauth/authorize
Token Endpoint: https://github.com/login/oauth/access_token
User Info Endpoint: https://api.github.com/user
Scopes:
read:user- Read user profileuser:email- Access email addresses
id(GitHub user ID)name(orloginas fallback)email(from profile or/user/emailsendpoint)avatar(avatar_url)
Google Provider
Authorization URL:https://accounts.google.com/o/oauth2/v2/auth
Token Endpoint: https://oauth2.googleapis.com/token
User Info Endpoint: https://www.googleapis.com/oauth2/v3/userinfo
Scopes:
openid- OpenID Connectprofile- Basic profile infoemail- Email address
access_type: offline- Request refresh tokenprompt: consent- Force consent screen
id(sub)nameemailavatar(picture)
Error Handling
All callback endpoints handle these error scenarios:Provider returned an error during authorization
State parameter mismatch (possible CSRF attack)
Authorization code missing from callback
Token exchange or profile fetch failed
Bind-Specific Errors
Bind target user ID cookie missing
Provider account already bound to different user
Environment Variables
Required configuration for each provider:SecondMe
GitHub
Next Steps
Login Endpoints
Detailed documentation for all login endpoints
Callback Handling
OAuth callback processing and validation