Managing Authentication
Authentication is one of the trickiest parts of browser automation. Websites often implement measures like CAPTCHAs, rate-limiting, or bot detection to prevent automated logins, making authentication challenging. Fortunately, Aidolon Browser offers multiple effective ways to handle authentication, such as logging in manually via the live viewer, automating logins carefully through safe commands, or ideally, logging in once and reusing your authenticated session context indefinitely.
What You'll Learn
- How to manage authentication efficiently
- Logging in manually via the live session viewer
- Saving and reusing browser session context
- Creating separate accounts for your automation agents
- Best practices for maintaining security
Why Authentication is Tricky
Automating logins can be frustrating because websites often:
- Block automated interactions
- Use CAPTCHAs to prevent bots
- Implement rate limits or ban IP addresses
Instead of fighting these issues repeatedly, it's easier to log in once manually, then save and reuse the authenticated session.
Authentication Workflow
Here's a visual overview of the recommended workflow:
Step-by-Step Guide
Step 1: Create and Log In via Live Session Viewer
First, create a browser session and manually log in to your account using the live viewer URL.
from aidolon_browser_client.browser.browser_session import BrowserSession
with BrowserSession() as browser:
print(f"Open this URL to log in manually: {browser.live_viewer_url}")
input("Press Enter after logging in manually...")
# Step 2: Save authenticated context
context = browser.get_context()
Open the printed URL in your browser and manually log in to your desired account.
Note: Typing text directly through Aidolon Browser commands (like
type_text) is safe—the underlying LLMs never see your sensitive information. However, manual login through the live viewer is simpler and avoids issues like CAPTCHAs.
Step 3: Reuse the Session Context
Whenever you need an authenticated session again, create a new session using the saved context:
from aidolon_browser_client.browser.browser_session import create_session
# Load previously saved context
with create_session(context=context) as browser:
browser.navigate("https://example.com/dashboard") # You're already logged in!
# Your automation tasks here
Now, you don't need to repeat the login process, saving time and credits.
Creating Separate Accounts for Your Agents
It's a best practice to create dedicated accounts specifically for automated tasks. Never use your personal or main business accounts for browser automation. Creating separate accounts ensures that:
- Your personal data remains secure and uncompromised.
- Automated activities remain isolated from your primary accounts.
- You can easily monitor and manage automated activity separately.
Always ensure these accounts have only the necessary permissions required for their tasks.
Best Practices for Authentication Security
- Never automate logins with your personal accounts. Create dedicated agent accounts to isolate automated tasks.
- Regularly refresh your saved context to avoid unexpected session expirations.
- Store session contexts securely, ideally encrypted.
- Immediately close sessions when finished:
browser.close_session()
Complete Authentication Example
Here's the full authentication workflow in action:
from aidolon_browser_client.browser.browser_session import BrowserSession, create_session
import json
# Step 1 and 2: Log in manually via live viewer and save context
with BrowserSession() as browser:
print(f"Login manually here: {browser.live_viewer_url}")
input("Press Enter after logging in...")
context = browser.get_context()
# Save context securely (example: save to file)
with open("session_context.json", "w") as f:
json.dump(context, f)
# Step 3: Reuse context in future sessions
with open("session_context.json", "r") as f:
saved_context = json.load(f)
with create_session(context=saved_context) as browser:
browser.navigate("https://example.com/dashboard")
# Your automation tasks here
Now you can manage authentication effortlessly and securely with Aidolon Browser!