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

# 登录 Olostep CLI

> 使用你的 Olostep 账户登录，检查你的身份，注销，并在 CI 中使用令牌。

CLI 使用你的 Olostep 账户登录，与在 [dashboard](https://www.olostep.com/dashboard) 上使用的账户相同。你不需要粘贴 API 密钥。

大多数命令需要你登录。`--help`、`olostep help` 和 `olostep feedback` 不需要。

## 登录

```bash theme={null}
olostep login
```

你的浏览器会打开 Olostep 登录页面。登录后，CLI 会在这台电脑上保存登录状态。你会保持登录状态，直到你运行 `olostep logout`。

如果你在登录前运行了需要登录的命令，CLI 会显示 `Please sign in to Olostep to continue.`，并提供两个选项，**Sign in** 和 **Exit**。选择 **Sign in** 以打开浏览器；登录后命令会继续执行。

## 检查你的身份

```bash theme={null}
olostep whoami
```

打印你的账户、你的团队、团队的计划和信用余额。`olostep whoami` 与 `olostep account info` 是相同的命令。

```bash theme={null}
olostep whoami --json
```

## 注销

```bash theme={null}
olostep logout
```

Olostep 撤销这台电脑的连接，CLI 忘记保存的登录状态。其他电脑保持登录状态。

## 脚本、CI 和代理

脚本或 CI 任务无法完成浏览器登录。给它一个令牌，使用 `OLOSTEP_TOKEN` 环境变量或任何命令上的 `--token` 标志：

```bash theme={null}
export OLOSTEP_TOKEN="<token>"
olostep credits balance --json
```

```bash theme={null}
olostep credits balance --json --token "<token>"
```

`OLOSTEP_TOKEN` 或 `--token` 中的令牌代替保存的登录状态。

当需要登录的命令在没有终端的情况下运行，或从编码代理运行，并且没有登录或令牌时，CLI 不会提示。它会将以下信息打印到 stderr 并以代码 `3` 退出：

```text theme={null}
Please sign in to Olostep to continue. Run `olostep login` (or set OLOSTEP_TOKEN), then run this again.
```

在脚本中检查退出代码 `3`：

```bash theme={null}
olostep credits balance --json > balance.json
if [ $? -eq 3 ]; then
  echo "Sign in first: olostep login"
fi
```

查看每个代码的 [退出代码](https://docs.olostep.com/cli/usage.md#exit-codes)。

## 登录信息存储位置

CLI 将登录信息保存在 `~/.config/olostep`（如果你设置了 `XDG_CONFIG_HOME`，则为 `$XDG_CONFIG_HOME/olostep`）。该文件夹仅你的用户可读。

## API 密钥

CLI 不需要 API 密钥。调用 [Olostep API](https://docs.olostep.com/get-started/authentication.md) 的代码需要。要将你的一个密钥放入 `.env` 文件而不打印它：

```bash theme={null}
olostep keys reveal <key> --write-env .env
```

这会将 `OLOSTEP_API_KEY=...` 写入 `.env`。查看 [`olostep keys reveal`](https://docs.olostep.com/cli/reference/account-billing#olostep-keys-reveal)。


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