For AI Agent Users
This guide shows you how to authenticate your AI agents with websites that use Auth Agent. We’ll use the browser-use library as an example, which is the recommended way to integrate Auth Agent with your agents.Overview
When your agent encounters a website that requires Auth Agent authentication:- The agent navigates to the sign-in page
- Clicks the “Sign in with Auth Agent” button
- A spinning authentication page appears
- Your agent automatically authenticates using Auth Agent tools
- The website grants access and redirects to the dashboard
Step 1: Create Agent Credentials
1
Navigate to Agent Console
2
Create New Agent
Click “Create New Agent” and enter:
- Your email address
- Agent name (e.g., “My Shopping Assistant”)
3
Copy Credentials
Save your
agent_id and agent_secret securely. You’ll need these to authenticate.Keep your
agent_secret secure! Never commit it to version control. Use environment variables.Step 2: Install Dependencies
Install Browser-Use
Browser-use requiresuv for installation:
Install Auth Agent SDK
Step 3: Set Up Environment Variables
Create a.env file in your project:
.env file:
We recommend using
ChatBrowserUse which is optimized for browser automation (highest accuracy + fastest speed + lowest token cost). Get $10 free credits at https://cloud.browser-use.com/new-api-keyStep 4: Import Auth Agent Tools
TheAuthAgentTools class is included in the SDK package. Simply import it:
If you get an
ImportError, make sure you:- Installed the SDK:
uv pip install auth-agent-sdk - Have version 2.5.2 or later:
uv pip install --upgrade auth-agent-sdk
Step 5: Use in Your Agent
Create your agent script:How It Works
1
Agent Navigates to Sign-In
Your agent goes to the website’s sign-in page
2
Clicks Auth Agent Button
The agent clicks “Sign in with Auth Agent”
3
Spinning Page Appears
The website shows a spinning authentication page with
window.authRequest.request_id4
Agent Authenticates
Your
authenticate_with_auth_agent tool:- Extracts the
request_idfrom the page - Calls Auth Agent API to authenticate
- Waits for authentication to complete
5
Website Grants Access
The website receives the authorization code and creates a session
6
Redirect to Dashboard
The agent is redirected to the dashboard and can proceed with its task
What Happens Behind the Scenes
- Request ID Extraction: The tool reads
window.authRequest.request_idfrom the page using JavaScript - Authentication Request: The SDK sends a POST request to Auth Agent with your agent credentials
- Status Polling: The SDK polls the status endpoint until authentication completes
- Authorization Code: Once complete, the website receives an authorization code
- Token Exchange: The website exchanges the code for access tokens (happens server-side)
- Session Creation: The website creates a session based on the chosen integration scenario
Troubleshooting
Agent can't find request_id
Agent can't find request_id
Make sure the agent is on the spinning authentication page. The page should show “Authenticating AI Agent” with a spinner. The
window.authRequest.request_id is only available on this specific page.Authentication fails
Authentication fails
- Verify your
agent_idandagent_secretare correct - Check that your agent credentials are active in the console
- Ensure the website is using Auth Agent (check the URL contains auth-agent.com)
Timeout waiting for authentication
Timeout waiting for authentication
The default timeout is 30 seconds. If authentication takes longer, the website may be slow. The page should still redirect automatically even if the tool times out.
