guidesCLI Authentication

CLI Authentication

The BrainMaps CLI tool supports two methods of authentication:

  1. Interactive login with email and password
  2. Token-based authentication using environment variables

Using Environment Variables

For automated or scripted usage, you can authenticate using a token from the environment:

export BRAINMAPS_API_KEY=your_token_here
brainmaps --visual

Or directly when running the command:

BRAINMAPS_API_KEY=your_token_here brainmaps --visual

Getting a Token

  1. Log in to the BrainMaps platform
  2. Go to your Account Settings
  3. Navigate to the API Tokens section
  4. Click “Create New Token”
  5. Give your token a descriptive name
  6. Copy the token immediately (it won’t be shown again)

Token Security

  • Keep your token secure and never share it
  • Store tokens in environment variables or secure configuration files
  • Avoid committing tokens to version control
  • Revoke tokens immediately if they’re compromised

Using Tokens in Scripts

You can use tokens in shell scripts:

#!/bin/bash
export BRAINMAPS_API_KEY=your_token_here
brainmaps --visual

Or in your .env file:

BRAINMAPS_API_KEY=your_token_here

Token Validation

The CLI will automatically:

  • Verify the token on startup
  • Skip the login screen if the token is valid
  • Fall back to the login screen if the token is invalid or missing

Revoking Tokens

You can revoke tokens:

  1. Through the web platform
  2. Using the CLI: brainmaps token revoke <token_id>
  3. Tokens are automatically invalidated on logout
BrainMaps Documentation