> ## 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 and template discovery commands. Authenticate before listing, searching templates, running, or exporting tasks.

> [!NOTE]
>
> Starting with CLI v0.1.33, `template search`, `template view`, and `template version` require credentials. CLI v0.1.32 allowed these commands to browse the same template catalog without logging in.

Only setup and diagnostic commands can run without credentials:

```bash theme={null}
octoparse --help
octoparse --version
octoparse capabilities
octoparse doctor
octoparse browser status
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] [Open API keys page](https://www.octoparse.com/console/open-platform/api-keys)
>
> Create, copy, and manage Octoparse API keys from your account center.

**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.

## 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.

## 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

> [card] [Run your first task](https://www.octoparse.com/docs/en/cli/quick-start/run-your-first-task.md)
>
> List tasks, inspect a task, run it locally, and export data.

> [card] [Browse all commands](https://www.octoparse.com/docs/en/cli/reference/command-cheatsheet.md)
>
> Review authentication, task, local run, cloud run, and export commands.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.