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

# API 키 발급 및 로그인

> OAuth 또는 API 키로 Octoparse CLI를 인증하세요. CI 및 자동화 환경에서는 환경 변수나 stdin을 사용할 수 있습니다.

## 인증 요구 사항

대부분의 Octoparse CLI 명령에는 인증이 필요합니다. API 키 또는 OAuth 세션으로 계정을 식별하고 Octoparse 작업과 데이터에 대한 액세스를 승인합니다.

<Warning>로컬 `--task-file` 및 `.otd` 실행과 템플릿 검색 명령을 포함한 모든 기능 명령에는 유효한 자격 증명이 필요합니다. 작업을 나열하거나 템플릿을 검색, 실행 또는 내보내기 전에 인증하세요.</Warning>

<Note>CLI v0.1.33부터 `template search`, `template view`, `template version`에 자격 증명이 필요합니다. CLI v0.1.32에서는 로그인 없이 동일한 템플릿 카탈로그를 탐색할 수 있었습니다.</Note>

설정 및 진단 명령만 자격 증명 없이 실행할 수 있습니다.

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

## 로그인 방법

Octoparse CLI는 OAuth와 API 키라는 두 가지 로그인 방법을 지원합니다.

### OAuth(브라우저 기반)

브라우저 로그인 흐름을 열고 액세스 및 갱신 토큰을 로컬에 저장합니다.

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

API 키를 직접 관리하고 싶지 않거나 팀에서 SSO를 사용하는 경우 OAuth를 사용하세요.

### API 키

Octoparse 콘솔에서 API 키를 생성합니다.

<Card title="API 키 페이지 열기" icon="key" href="https://www.octoparse.kr/console/account-center/api-keys">계정 센터에서 Octoparse API 키를 생성, 복사 및 관리하세요.</Card>

**대화형 로그인** — API 키 페이지를 연 다음 키를 붙여 넣으라는 메시지를 표시합니다.

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

**키 직접 전달** — 복사한 키를 검증하고 저장합니다.

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

**브라우저 열기 방지:**

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

**stdin에서 키 읽기** — 비밀 관리자 및 CI 파이프라인용입니다.

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

예를 들어 1Password CLI에서는 다음과 같이 사용합니다.

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

<Note>CLI는 API 키를 저장하기 전에 검증합니다. 유효하지 않은 키는 저장되지 않습니다.</Note>

## 환경 변수 사용

CI 또는 임시 세션에서는 저장된 자격 증명 대신 환경 변수로 자격 증명을 제공합니다.

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

전달자 토큰 액세스(수명이 짧은 CI 작업에 유용):

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

API 기본 URL도 재정의할 수 있습니다.

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

## 자격 증명 우선순위

Octoparse CLI는 다음 순서로 자격 증명을 확인합니다.

```text theme={null}
1. OCTO_ENGINE_ACCESS_TOKEN  (전달자 토큰, 최우선)
2. OCTO_ENGINE_API_KEY       (API 키 재정의)
3. ~/.octoparse/credentials.json  (auth login으로 저장)
```

자격 증명 파일은 `octoparse auth login`에서 자동으로 생성됩니다.

macOS 및 Linux:

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

Windows:

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

<Warning>API 키나 토큰을 Git, 스크립트, 문서, 스크린샷, 공유 로그 또는 CI 출력에 커밋하지 마세요.</Warning>

## 인증 상태 확인 및 관리

세션이 활성 상태인지 확인합니다.

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

자세한 계정 및 자격 증명 정보를 표시합니다.

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

저장된 자격 증명을 제거합니다.

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

## 다음 단계

<CardGroup cols={2}>
  <Card title="첫 작업 실행" href="/docs/ko/cli/quick-start/run-your-first-task">작업을 나열하고 확인한 뒤 로컬에서 실행하고 데이터를 내보냅니다.</Card>
  <Card title="모든 명령 보기" href="../reference/command-cheatsheet">인증, 작업, 로컬 실행, 클라우드 실행 및 내보내기 명령을 검토합니다.</Card>
</CardGroup>
