Overview
iFlow authentication provides access to iFlow’s AI services through two methods:- OAuth 2.0 Flow - Standard OAuth authentication with browser
- Cookie Authentication - Direct authentication using browser cookies
Prerequisites
Before authenticating with iFlow, ensure you have:- An iFlow account with API access
- CLIProxyAPI server installed and configured
- Email address associated with your iFlow account
- For OAuth: A web browser
- For cookie auth: Browser cookies from an active iFlow session
Authentication Method 1: OAuth Flow
The OAuth flow provides standard browser-based authentication.Start OAuth login
Run the following command:This will:
- Start a local OAuth callback server
- Open your default web browser
- Navigate to iFlow’s OAuth authorization page
Complete authorization
In the browser:
- Sign in to your iFlow account
- Review the requested permissions
- Click “Authorize” to grant access
- Wait for automatic redirect to callback
Provide email address
When prompted, enter your iFlow account email:This email is required for account identification.
OAuth Flow Options
Manual Browser Mode
For headless servers or when the browser doesn’t open:Custom Callback Port
iFlow OAuth authentication requires an email address. If you don’t provide one when prompted, authentication will fail with an “EmailRequiredError”.
Authentication Method 2: Cookie Authentication
Cookie authentication allows you to use existing browser session cookies for quick setup.Get iFlow cookies from browser
Open your browser and sign in to iFlow. Then extract cookies:Chrome/Edge:
- Open DevTools (F12)
- Go to Application → Cookies
- Find iFlow’s domain
- Copy all cookie values
- Open DevTools (F12)
- Go to Storage → Cookies
- Find iFlow’s domain
- Copy cookie values
BXAuthor similar session identifiers- Authentication tokens
- Session IDs
Paste cookies
When prompted, paste your cookies:The CLI automatically:
- Normalizes cookie format
- Extracts BXAuth identifier
- Validates cookie structure
Check for duplicates
The CLI checks if this BXAuth already exists:
- If duplicate found: Authentication is skipped
- If unique: Proceeds with authentication
Comparison: OAuth vs Cookie Authentication
| Feature | OAuth Flow | Cookie Authentication |
|---|---|---|
| Browser required | Yes (OAuth flow) | Yes (to get cookies) |
| Setup speed | Moderate | Fast |
| Expiration handling | Automatic refresh | Manual re-auth needed |
| Security | OAuth 2.0 standard | Depends on cookie security |
| Best for | Long-term use | Quick testing/setup |
| Duplicate detection | No | Yes (by BXAuth) |
Configuration
Token Storage Location
Authentication tokens are stored in the configured auth directory:- Default location: Set via
-auth-diror in config file - Filename format:
iflow-<email>-<timestamp>.json - Example:
[email protected]
Token Contents
OAuth tokens contain:- OAuth 2.0 access token
- Refresh token (if provided)
- Token expiration
- Email address
- Authentication metadata
- API key extracted from session
- BXAuth identifier
- Cookie expiration
- Email address
- Original cookie values (normalized)
Email Address Requirements
The email address you provide:- Must match your iFlow account email
- Is required for both OAuth and cookie authentication
- Is used for token file naming and organization
- Identifies your account in logs and monitoring
Multiple Accounts
Authenticate with multiple iFlow accounts for increased capacity:- Creates a separate token file
- Has its own API key/tokens
- Is automatically loaded by the server
- Participates in credential rotation
Verification
To verify your authentication is working:Troubleshooting
OAuth Flow Issues
Email required error
Cause: No email address provided when prompted. Solution:- Run the login command again
- Enter your iFlow account email when prompted
- Complete the OAuth flow
Browser doesn’t open
Solution: Use manual browser mode:OAuth timeout
Cause: Authorization not completed quickly enough. Solution:- Complete OAuth flow faster
- Check firewall settings
- Verify callback port is accessible
Cookie Authentication Issues
Invalid cookie format
Cause: Cookies not properly formatted. Solution:- Ensure cookies are in
name=value; name2=value2format - Copy all relevant cookies from browser
- Don’t modify cookie values manually
- Check for line breaks or extra spaces
Cookie normalization failed
Cause: Cookie string couldn’t be parsed. Solution:Duplicate BXAuth detected
Cause: This BXAuth identifier already exists in your auth directory. Solution:- This is actually helpful - it prevents duplicate credentials
- If you want to refresh: delete the existing file first
- If using a different account: get cookies from that account’s session
Cookie authentication failed
Possible causes:- Cookies expired
- Invalid or incomplete cookies
- Not signed in to iFlow in browser
- Network connectivity issues
- Sign in to iFlow in your browser
- Get fresh cookies immediately
- Paste cookies into CLI promptly
- Ensure no line breaks or formatting issues
API key not returned
Cause: iFlow servers didn’t return an API key. Solution:- Verify your account has API access
- Check if cookies are still valid
- Sign in to iFlow web interface to refresh session
- Contact iFlow support if issue persists
Common Issues (Both Methods)
Token not saving
Cause: Permission issues with auth directory. Solution:Email format invalid
Cause: Email address format is incorrect. Solution:- Must be valid email format:
[email protected] - No spaces or special characters except
@,.,+,-,_ - Must match your actual iFlow account email
Security Considerations
OAuth Authentication Security
- Uses standard OAuth 2.0 protocols
- Tokens are refreshed automatically
- Refresh tokens enable long-term access
- Revocable through iFlow account settings
Cookie Authentication Security
- Less secure than OAuth - cookies can be intercepted
- No automatic refresh - manual re-auth needed when expired
- BXAuth is sensitive - treat like a password
- Duplicate detection prevents accidental credential duplication
Token File Security
Both methods store sensitive credentials:- Files use
0600permissions (owner-only read/write) - Auth directory should be
755(rwxr-xr-x) - Never commit token files to git
- Include auth directory in
.gitignore - Back up securely if needed
Token Expiration and Refresh
OAuth Tokens
- Automatically refreshed by the server
- Refresh tokens enable seamless renewal
- No manual intervention required
- Check logs for refresh failures
Cookie Tokens
- Not automatically refreshed
- Expire when browser session expires
- Require manual re-authentication
- Expiration date shown during authentication
- Delete the expired token file
- Get fresh cookies from browser
- Run
-iflow-cookieagain
Re-authentication
Re-authenticate OAuth
Re-authenticate Cookie
Best Practices
-
Choose the right method:
- Production: Use OAuth flow
- Testing: Cookie auth is acceptable
- Long-term: OAuth provides automatic refresh
-
Email management:
- Use the correct email for your iFlow account
- Different emails for different accounts
- Email in filename helps identify credentials
-
Cookie handling:
- Get cookies from secure HTTPS sessions only
- Copy immediately after signing in
- Delete from browser DevTools after copying
- Don’t store cookies in plaintext elsewhere
-
Multiple accounts:
- Mix OAuth and cookie methods if needed
- Each account needs unique email
- Server handles credential rotation automatically
-
Security:
- Protect token files like passwords
- Use appropriate file permissions
- Monitor auth directory for unauthorized access
- Re-authenticate if tokens may be compromised