Anchor Browser enables secure connections to services that require authentication, without exposing credentials or cookies directly to the AI agent. This guide covers two supported methods for achieving secure access.

In this method, Anchor Browser uses a pre-authenticated browser context to access protected resources. This approach is recommended because it maintains a secure, isolated environment for authentication without exposing sensitive data.

1

Authenticate Once

Start by logging into the target service in a dedicated browser session. This creates a browser context with the required cookies and session data.

2

Export Browser Context

Once authenticated, export the browser context (including cookies and session data) and save it securely.

You can also export the browser context manually from your local browser by saving cookies and session data, using tools like browser devtools or extensions. - How to manually collect the context object
3

Mount in Anchor Browser

Use the saved browser context within Anchor Browser to access authenticated services seamlessly.

For cases where browser context mounting isn’t feasible, Playwright allows direct injection of cookies into a browser session, enabling access to authenticated resources.

1

Obtain Authentication Cookies

Authenticate manually or programmatically to capture the required cookies.

2

Inject Cookies into Playwright Session

Use Playwright’s API to inject cookies into the browser session before navigating to the authenticated page.

3

Access Resources

With the cookies injected, the AI agent can interact with the protected service as if logged in.

Code example

Secure Storage of Secrets

To maintain the security of your credentials, API keys, and sensitive data, do not store secrets directly in plaintext within your code. Instead, consider these best practices:

  1. Environment Variables: Store secrets in environment variables. You can use libraries such as dotenv for Node.js to load variables from a .env file.
  2. Secrets Management Services: Use secure storage solutions like AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault to manage sensitive data securely.