login

A command that signs in to xAI through OAuth, a standard way for an app to request permission to act for your account.

In plain words
What is it for?
Use it to start a browser-based login, choose a custom callback port or timeout, avoid opening a browser, or paste the authorization result manually.
Why use it?
It creates and saves the local login information needed by other commands, including cases where the browser callback does not work automatically.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/moore-developers/grok-cli/login
Clone the repo
git clone --depth 1 https://github.com/Moore-developers/grok-cli
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 530 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00530
Opus 5 $0.00000 $0.00265
Sonnet 5 $0.00000 $0.00106
Haiku 4.5 $0.00000 $0.00053

Measured 2d ago against content hash 84d84f193f21, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

login scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/commands/login.md · 82 lines

How it starts

The opening of the file, as written. The whole thing — 82 lines — stays where its author put it; the contents beside it link to each section on GitHub.

grok-cli login

Purpose

Start xAI OAuth PKCE login. By default, the command opens the system browser and exchanges the authorization code for tokens when the local loopback callback arrives.

Default auth state path:

~/.grok-cli/auth.json

Common Usage

grok-cli login

Script or skill usage:

grok-cli login --json

If the browser cannot complete the local callback, use manual paste mode:

grok-cli login --manual-paste

Print login flow status and use a custom port:

grok-cli login --port 56121 --timeout 180

Parameters

  • --json: use the standard JSON envelope.
  • --auth-file <PATH>: override the OAuth state file path.
  • --no-browser: do not automatically open a browser; only prepare the local login state.
  • --manual-paste: use manual callback / authorization code paste mode.
  • --timeout <SECONDS>: loopback callback wait timeout.
  • --port <PORT>: local callback port.

Behavior

  • Generates the PKCE verifier / challenge, OAuth state, and nonce.
  • Builds the xAI authorization URL with referrer=hermes-agent and plan=generic.
  • Writes the pending OAuth session to auth.json.
  • Opens the real system browser by default.
  • On a successful loopback callback, automatically exchanges the authorization code.
  • If the callback times out in an interactive terminal, the command falls back to manual paste.
  • On success, writes access token, refresh token, redirect URI, and last refresh metadata.

JSON Output

Success:

{
  "ok": true,
  "command": "login",
  "data": {
    "provider": "xai-oauth",
    "auth_mode": "oauth_pkce",
    "saved": true,
    "auth_store_path": "~/.grok-cli/auth.json",
    "redirect_uri": "http://127.0.0.1:56121/callback",
    "base_url": "https://api.x.ai/v1"
  }
}

Failures follow the standard error envelope. Common errors include auth_callback_timeout, auth_state_mismatch, and auth_token_exchange_failed.

Read the full file on GitHub · 82 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 82 lines · 0 tokens per session scan A 84d84f193f21

Subscribe to this mod's changes

login is a command published in the GitHub repository Moore-developers/grok-cli (52 stars, last pushed 19d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 530 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.