> ## Documentation Index
> Fetch the complete documentation index at: https://www.octoparse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get an API key and log in

> Authenticate Octoparse CLI with OAuth or an API key. Use an environment variable or stdin for CI and automated environments.

## Authentication requirements

Most Octoparse CLI commands require authentication. An API key or OAuth session identifies your account and authorizes access to your Octoparse tasks and data.

<Warning>
  All functional commands require valid credentials, including local `--task-file` and `.otd` runs. Authenticate before listing, running, or exporting tasks.
</Warning>

Only setup and diagnostic commands can run without credentials:

```bash theme={null}
octoparse --help
octoparse --version
octoparse capabilities
octoparse doctor
octoparse browser doctor
octoparse auth
octoparse auth info
```

## Login methods

Octoparse CLI supports two login methods: OAuth and API key.

### OAuth (browser-based)

Open a browser login flow and store access and refresh tokens locally:

```bash theme={null}
octoparse auth login --oauth
```

Use OAuth when you prefer not to manage API keys manually or when your team uses SSO.

### API key

Create API keys in the Octoparse console:

<Card title="Open API keys page" icon="key" href="https://www.octoparse.com/console/account-center/api-keys">
  Create, copy, and manage Octoparse API keys from your account center.
</Card>

**Interactive login** — opens the API key page, then prompts you to paste a key:

```bash theme={null}
octoparse auth login
```

**Pass the key directly** — verifies and stores a copied key:

```bash theme={null}
octoparse auth login <apiKey>
```

**Avoid opening the browser:**

```bash theme={null}
octoparse auth login --no-open
```

**Read the key from stdin** — for secret managers and CI pipelines:

```bash theme={null}
echo "<apiKey>" | octoparse auth login --stdin
```

For example, with 1Password CLI:

```bash theme={null}
op read "op://vault/octoparse/credential" | octoparse auth login --stdin
```

<Note>
  The CLI verifies the API key before saving it. Invalid keys are not stored.
</Note>

## Use an environment variable

For CI or temporary sessions, provide credentials through environment variables instead of stored credentials:

```bash theme={null}
OCTO_ENGINE_API_KEY=xxx octoparse task list --json
```

For bearer token access (useful in short-lived CI jobs):

```bash theme={null}
OCTO_ENGINE_ACCESS_TOKEN=xxx octoparse task list --json
```

You can also override the API base URL:

```bash theme={null}
OCTO_ENGINE_API_BASE_URL=https://example.com OCTO_ENGINE_API_KEY=xxx octoparse task list
```

## Credential precedence

Octoparse CLI checks credentials in this order:

```text theme={null}
1. OCTO_ENGINE_ACCESS_TOKEN  (bearer token, highest priority)
2. OCTO_ENGINE_API_KEY       (API key override)
3. ~/.octoparse/credentials.json  (stored by auth login)
```

The credentials file is created automatically by `octoparse auth login`.

On macOS and Linux:

```text theme={null}
~/.octoparse/credentials.json
```

On Windows:

```text theme={null}
%USERPROFILE%\.octoparse\credentials.json
```

<Warning>
  Do not commit API keys or tokens to Git, scripts, docs, screenshots, shared logs, or CI output.
</Warning>

## Check and manage auth status

Confirm your session is active:

```bash theme={null}
octoparse auth status
```

Show detailed account and credential info:

```bash theme={null}
octoparse auth info
```

Remove saved credentials:

```bash theme={null}
octoparse auth logout
```

## What's next

<CardGroup cols={2}>
  <Card title="Run your first task" href="run-your-first-task">
    List tasks, inspect a task, run it locally, and export data.
  </Card>

  <Card title="Browse all commands" href="../reference/command-cheatsheet">
    Review authentication, task, local run, cloud run, and export commands.
  </Card>
</CardGroup>
