Files
dify-docs/zh/cli/authenticate.mdx
Riskey 2f88f0f7d2 docs: sync Cloud documentation for Dify 1.15.0 (#835)
* docs: add Human Input file inputs and Service API to Cloud docs

Port the Phase 2 Human Input docs (file inputs and the Service API integration flow) to the Cloud docs, mirroring the self-host pages.

- human-input.mdx (en/zh/ja): add the Single File / File List field type and the file-handling notes; the upload-limit callout states Cloud's fixed limits (documents 15 MB, images 10 MB, audio 50 MB, video 100 MB, up to 10 files) instead of self-host env vars.
- hitl-api-integration-flow.mdx (en/zh/ja): new; identical to self-host since the Service API is the same.
- docs.json: nest the integration-flow under the Human Input group in all three navs.
- zh/ja reuse the self-host translations; only the callout and the /self-host/ links changed.

* docs: rewrite Cloud model providers around AI Credits

* docs: rewrite Cloud subscription management for 1.15.0

* docs: update Cloud code node limits and XLSX image extraction note

* docs: rewrite Cloud team members management for 1.15.0

* docs: apply the 1.15.0 Integrations redesign to Cloud docs

* docs: fix workflow API reference for run-level logs and streaming

* docs: sync self-host use-dify pages and fix translation debt

* docs: align shared tutorials and quick start with 1.15.0

* docs: refine difyctl install examples and workspace reference

* docs: rewrite hotkeys page to match current shortcuts

* fix: correct broken anchor links for badged headings and tabs

* fix: correct env link and Human Input resume identifier

* feat: handle heading badges in link-checker slugs

* fix: repoint publish-mcp cross-links to the merged MCP section

* docs: rename plugin dev CLI to Dify Plugin CLI

* docs: refine CLI reference readability and expand --agent

* feat: stop format checkers flagging indented list-item content

* fix: correct zh/ja custom-endpoint spacing and a list blank line

* docs: clarify Cloud model provider install and AI Credits coverage
2026-07-02 19:51:55 +08:00

111 lines
3.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 认证
description: 从 CLI 登录你的 Dify 主机,了解 token 的存储位置,并管理你的会话
---
> 本文档由 AI 自动翻译。如有任何不准确之处,请参考 [英文原版](/en/cli/authenticate)。
登录通过浏览器完成,使用 OAuth 2.0 设备流程,`difyctl` 全程接触不到你的密码。
## 登录
<Steps>
<Step title="运行登录命令">
传入 Dify 主机的 URL。使用 Dify Cloud 时,填写 `https://cloud.dify.ai`;自部署时,使用 [控制台 API URL](/zh/self-host/deploy/configuration/environments#console_api_url)。
```bash
difyctl auth login --host https://cloud.dify.ai
```
`difyctl` 会打印一次性验证码,在默认浏览器中打开验证 URL,然后等待:
```text
! Copy this one-time code: WDJP-XKLM
Open: https://cloud.dify.ai/device
```
<Tip>
若不想自动打开浏览器,可传入 `--no-browser`。
</Tip>
如果没有浏览器打开(通过 SSH 或在无图形界面的会话中属正常现象),可自行在任意设备上打开该 URL。
</Step>
<Step title="在浏览器中确认登录">
在打开的浏览器标签页中,用 Dify 凭据登录并输入一次性验证码。
验证码 15 分钟后过期。若已过期,重新运行 `difyctl auth login` 获取一个新的。
</Step>
<Step title="确认会话">
回到终端:
```text
✓ Logged in to cloud.dify.ai as <your-email> (<your-name>)
Workspace: <your-workspace>
```
第二行是你的工作空间。
</Step>
</Steps>
## 重新登录
如果某条命令以 `auth_expired`(退出码 4)失败,说明服务器已使你的会话过期或将其吊销。
重新运行 `difyctl auth login`。无需先登出,新的登录会刷新已存储的 token。
## 查看当前登录身份
```bash
difyctl auth whoami
```
```text
<your-email> (<your-name>)
```
要在脚本中读取身份信息,加上 `--json`:
```bash
difyctl auth whoami --json
```
你会得到相同的字段(以 JSON 对象形式返回),外加你的账户 ID:
```json
{"id":"3c90c3cc-0d44-4b50-8888-8dd25736052a","email":"<your-email>","name":"<your-name>"}
```
## 登出
```bash
difyctl auth logout
```
```text
✓ Logged out of cloud.dify.ai
```
这会吊销服务器上的会话,并从你的机器上删除 token 和会话记录。即便服务器端的吊销失败,本地凭据仍会被清除。
## Token 的存储位置
登录后会存储一个 OAuth bearer token,可通过 `dfoa_` 前缀识别。它代表你本人:你的账户在工作空间中能做什么,这个 token 在 CLI 中就能做什么。
只要操作系统提供凭据存储,`difyctl` 就会把 token 存入其中:macOS 上是 KeychainWindows 上是 Credential ManagerLinux 上是 Secret Service。如果没有可用的凭据存储,则回退到 `difyctl` 配置目录下一个权限为 `0600` 的 `tokens.yml` 文件。
`difyctl` 在你登录时选定存储位置,此后整个会话都使用它。会话元数据(主机、账户、工作空间)与 token 一同保存在 `hosts.yml` 中。
配置目录在 macOS 和 Linux 上是 `~/.config/difyctl`Linux 遵循 `XDG_CONFIG_HOME`),在 Windows 上是 `%APPDATA%\difyctl`。设置 [`DIFY_CONFIG_DIR`](/zh/cli/reference/environment-variables) 可覆盖此路径。
## 故障排查
| 问题 | 处理方法 |
|:---|:---|
| 浏览器始终未打开 | 从终端复制 URL,在任意设备上打开。 |
| 主机被拒绝 | 只接受 `https://` 主机;不带协议的主机默认按 `https://` 处理。对于纯 `http://` 主机(仅限本地开发),加上 `--insecure`。 |
| 后续某条命令以 `auth_expired` 失败 | 你的会话已过期或被吊销。[重新登录](#重新登录)。 |
其余问题详见完整的 [故障排查](/zh/cli/troubleshooting) 页面。