Skip to main content
This guide walks you through using the 1Password SDK with Stagehand and Playwright to securely authenticate on websites without hardcoding credentials.
This guide assumes you have a 1Password account and a Browserbase account. If you don’t, create a 1Password account and Browserbase account.

1. Create your 1Password vault

Create a specific vault structure for this integration.

Create the vault

  1. Open the 1Password app and sign in to your account
  2. Click the plus + button in the sidebar
  3. Name your vault: Browserbase Agent
  4. Optionally add a description like “Credentials for Browserbase automation”
  5. Click Create

Add your Browserbase credentials

  1. In your new Browserbase Agent vault, click New Item
  2. Select Login as the item type
  3. Fill in the details:
    • Title: Browserbase
    • Username: Your Browserbase email address
    • Password: Your Browserbase password
  4. Click Save
Your vault structure should now be: op://Browserbase Agent/Browserbase/username and op://Browserbase Agent/Browserbase/password

2. Create a service account

Create a Service Account to allow programmatic access to your vault.
You need admin access to your 1Password account to create a Service Account.
  1. Navigate to 1Password.com and sign in
  2. Go to the Developer tab in the sidebar
  3. Under Service Accounts, click New Service Account
  4. Name your Service Account: Browserbase Agent Account
  5. Select the vault you created in Step 1: Browserbase Agent
  6. Click Create Account
  7. IMPORTANT: Copy the Service Account token that appears
This Service Account token is sensitive and will only be shown once. Store it securely - you’ll need it for the OP_SERVICE_ACCOUNT_TOKEN environment variable.

3. Install dependencies

4. Configure environment

Create a .env file in your project root:
.env

5. Implement authentication

Create an index.ts file with the following code:
index.ts

6. Run your script

Execute your script to see the 1Password integration in action:

Next steps

Contexts

Learn more about using contexts to automate workflows across login-gated sites

Session recordings

Learn more about using session recordings to debug and optimize your workflows