Skip to main content

CLI Commands

login

The login command authenticates you with the Cogni+ platform using a browser-based flow.

Usage

cogni login [OPTIONS]

Description

The login command opens your browser to authenticate with Cogni+ and automatically captures the session for use with the CLI. This browser-based authentication allows you to leverage existing web sessions, making the login process seamless if you’re already logged in to Cogni+ in your browser. Once authenticated, the session is stored securely in your local configuration file and used for subsequent CLI commands that require authentication.

Options

OptionDescription
--port INTEGERPort to use for the local callback server (default varies)
--forceForce re-authentication even if already logged in
--environment TEXTAPI environment to use (local, development, staging, production)
--debugEnable debug output for troubleshooting
--helpShow help message for the login command

Authentication Flow

  1. The CLI starts a local web server to receive the authentication callback
  2. Your default web browser opens to the Cogni+ authentication page
  3. After you authenticate in the browser, Cogni+ redirects back to the local server
  4. The CLI captures the session token and stores it in your config file
  5. The browser window can be closed, and the CLI confirms successful authentication

Examples

# Basic login
cogni login

# Force re-authentication
cogni login --force

# Connect to a specific environment
cogni login --environment development

# Use a specific port for the callback server
cogni login --port 9000

# Enable debug output for troubleshooting
cogni login --debug

Output

A successful login will display:
Opening browser for authentication...
Browser opened to https://cogni.plus/auth/cli?callback=http://localhost:8789
Waiting for login callback...
Successfully logged in as [email protected]
Auth token saved to ~/.cogni/config.json

Environments

Cogni+ supports multiple environments that you can connect to:
  • production: The main production environment (default)
  • staging: Pre-production testing environment
  • development: Development environment
  • local: For connecting to a locally running Cogni+ instance
  • cogni logout - Log out from Cogni+ by removing stored session
  • cogni init - Initialize Cogni+ CLI with an interactive setup wizard

Tips

  • If your browser doesn’t open automatically, the CLI will display a URL you can copy and paste
  • Sessions are valid for extended periods, so you typically won’t need to log in frequently
  • Use the --force flag if you need to switch users or refresh your session
  • If you’re having connectivity issues, try using the --debug flag to see more details