Handling Authentication
Managing 2FA and other authentication flows.
Authentication flows, along with anti-bot detection, add complexity to web automation. Two-factor authentication and captchas are challenging to overcome, and executing typical authentication flows slow down automation.
Browserbase has a number of built-in features to tackle automation, like Stealth Mode and reuse of session cookies.
Accessing an authentication flow with Stealth Mode
Many authentication flows implement mechanisms to prevent web automation:
- IP addresses restrictions
- User agent filtering
- Captchas (ex: Clerk now features a captcha challenge on all authentication flows)
- Rate limiting
When running your browser session, dealing with these impediments may require setting up IP rotations with proxies along with captcha solving and fingerprint generators.
By automating with Browserbase, you get opt-in proxies, automatic, fully configurable fingerprinting, and captcha solving—without any coding:
Speed up your automation by reusing cookies
Some websites or web apps rely on cookies-based Sessions, which can be easily retrieved and reused to speed up your automation.
The code examples below showcases how to retrieve and set cookies to avoid your automation to go through the authentication flow at each run:
Working with two-factor authentication
Two-step verification (via authenticator apps or SMS) or magic links require human intervention in the loop. Here are some strategies for managing 2FA:
Disable 2FA or create an app password
This approach applies to authentication flows owned by your team or company.
For an internal tool, try to turn off the two-step verification.
For an authentication flow requiring some level of security, try to create an app password.
Enable Remote Control of your Session
If a two-step verification mechanism cannot be bypassed or disabled, consider handing back control to the end user by leveraging the Session Live URLs.
Taking a Session's Remote Control with Session Live View
Let your end users complete the two-step verification process as part of your automation.
Using Anon to handle Authentication
We partner with Anon which provides a comprehensive authentication solution for many websites. To learn more about using Anon to handle authentication, or to see the list of currently-supported websites, check out Anon’s developer docs.
Was this page helpful?