Overview
Browser Use provides multiple strategies for handling authentication:- Cookie/Session Sync - Reuse your local browser sessions
- Sensitive Data - Securely pass credentials to the agent
- 2FA Integration - Automate time-based codes
- Cloud Profiles - Persistent authentication in production
Cookie and Session Management
Using Your Real Browser
Connect to your existing Chrome profile to preserve all authentication:Export/Import Storage State
Save cookies and localStorage for reuse:1
Export Storage State
2
Import Storage State
Sensitive Data
Pass credentials securely without hardcoding:Basic Usage
Domain-Specific Credentials
Organize credentials by domain:2FA Authentication
Time-Based OTP (TOTP)
Automate 2FA codes withpyotp:
Custom 2FA Tool
For more control, create a custom tool:SMS/Email 2FA
Implement human-in-the-loop for manual codes:Production: Cloud Profiles
For production deployments, sync your local cookies to the cloud:1
Get API Key
Create an API key at cloud.browser-use.com/new-api-key
2
Sync Local Cookies
Run the profile sync script:This opens a browser where you log into your accounts. You’ll get a
profile_id.3
Use in Production
Common Authentication Patterns
Form-Based Login
OAuth Flow
Multi-Step Authentication
SSO / SAML
Session Persistence
Keep Browser Alive
Maintain session across multiple agent runs:Export State Mid-Session
Security Best Practices
1
Never Hardcode Credentials
✅ Good:❌ Bad:
2
Use .gitignore
Exclude sensitive files:
.gitignore
3
Rotate Credentials
4
Monitor Authentication
Troubleshooting
Session Expired
CAPTCHA Handling
Use cloud browsers with captcha bypass:Cookie Domain Mismatch
Next Steps
Production Deployment
Deploy with @sandbox and cloud profiles
Custom Tools
Build custom authentication flows
Browser Configuration
Advanced browser settings
Sensitive Data
See more examples