ClaudeWrapper.Commands.Auth (ClaudeWrapper v0.8.1)

Copy Markdown View Source

Authentication commands -- login, logout, status, token setup.

Summary

Types

Which billing path the CLI should authenticate against.

Functions

Login via browser. This is interactive -- the CLI will open a browser.

Logout.

Set up an API token directly.

Check authentication status.

Types

auth_status()

@type auth_status() :: %{
  logged_in: boolean(),
  auth_method: String.t() | nil,
  api_provider: String.t() | nil,
  email: String.t() | nil,
  org_id: String.t() | nil,
  org_name: String.t() | nil,
  subscription_type: String.t() | nil,
  extra: map()
}

login_mode()

@type login_mode() :: :claudeai | :console

Which billing path the CLI should authenticate against.

Maps to --claudeai (Claude subscription) or --console (Anthropic Console / API usage billing) on claude auth login. The CLI defaults to :claudeai when neither flag is passed; setting :console is the only way Console-billed teams reach their account.

Functions

login(config, opts \\ [])

@spec login(
  ClaudeWrapper.Config.t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}

Login via browser. This is interactive -- the CLI will open a browser.

Options

  • :email -- pre-populate the email address on the login page (--email <email>).
  • :mode -- pin the billing path. :claudeai (the CLI default, maps to --claudeai) or :console (maps to --console, required for teams on Anthropic Console billing).
  • :force_sso -- when true, force the SSO login flow (--sso).

Examples

# Default subscription login
{:ok, _} = ClaudeWrapper.Commands.Auth.login(config)

# Console-billed login, pre-filling the email
{:ok, _} =
  ClaudeWrapper.Commands.Auth.login(config,
    mode: :console,
    email: "ops@example.com"
  )

logout(config)

@spec logout(ClaudeWrapper.Config.t()) :: {:ok, String.t()} | {:error, term()}

Logout.

setup_token(config, token)

@spec setup_token(ClaudeWrapper.Config.t(), String.t()) ::
  {:ok, String.t()} | {:error, term()}

Set up an API token directly.

status(config)

@spec status(ClaudeWrapper.Config.t()) :: {:ok, auth_status()} | {:error, term()}

Check authentication status.

Returns parsed status if the CLI supports JSON output, raw text otherwise.