Documentation Index
Fetch the complete documentation index at: https://mintlify.com/GoodnessFx/GatePass/llms.txt
Use this file to discover all available pages before exploring further.
Overview
GatePass supports OAuth 2.0 authentication with Google and Twitter. Social authentication allows users to sign in using their existing social media accounts without creating a separate password.Supported Providers
Google OAuth
Sign in with Google account
Twitter OAuth
Sign in with Twitter account
Google Authentication
Initiate Google OAuth Flow
profile: Access to user’s basic profile informationemail: Access to user’s email address
Example
cURL
Google OAuth Callback
- Verifies the OAuth code from Google
- Creates or updates the user account
- Generates JWT access and refresh tokens
- Redirects to the frontend with the access token
Twitter Authentication
Initiate Twitter OAuth Flow
Example
cURL
Twitter OAuth Callback
- Verifies the OAuth token from Twitter
- Creates or updates the user account
- Generates JWT access and refresh tokens
- Redirects to the frontend with the access token
OAuth Callback Handling
Frontend Implementation
Handle the OAuth callback in your frontend application:Session Management
Token Structure
After successful OAuth authentication, users receive:-
Access Token (returned in redirect URL)
- Valid for 15 minutes
- Contains user ID, email, and role
- Used for API authentication
-
Refresh Token (stored in HttpOnly cookie)
- Valid for 7 days
- Stored securely in database
- Used to obtain new access tokens
Refresh Token Cookie
The refresh token is automatically set as an HttpOnly cookie with these properties:User Account Creation
When a user authenticates via OAuth for the first time:-
A new user account is created with:
- Email from OAuth provider
- Name from OAuth provider profile
- Default role:
USER - No password (OAuth users don’t need passwords)
-
If the user already exists (matched by email):
- The existing account is used
- Profile information may be updated
Environment Configuration
To enable OAuth authentication, configure these environment variables:Security Considerations
Session Security
Session Security
- OAuth sessions use the same security measures as email/password authentication
- Refresh tokens are stored securely in HttpOnly cookies
- Access tokens have short expiration times (15 minutes)
- All tokens are signed with JWT secrets
Account Linking
Account Linking
- OAuth accounts are linked by email address
- Users cannot have multiple accounts with the same email
- If a user signs up with email/password, they can later use OAuth with the same email
Data Privacy
Data Privacy
- Only necessary scopes are requested (profile and email)
- OAuth provider tokens are not stored
- Users can revoke access from their OAuth provider settings
Error Handling
If OAuth authentication fails:- User is redirected to
/loginon the frontend - Common failure reasons:
- User denied authorization
- Invalid OAuth configuration
- Network errors
- Email already exists with different provider