Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Apple

了解如何配置 LibreChat 以使用 Apple 进行用户身份验证。

先决条件

在开始之前,请确保您已具备以下条件:

  • Apple Developer Account: 如果您还没有账号,请在此注册

创建新的 App ID

1. 登录 Apple Developer Console

2. 导航至 Identifiers

  • 前往 Certificates, Identifiers & Profiles
  • 点击侧边栏中的 Identifiers

3. 创建一个新的 App ID

  1. 点击 "+" 按钮以添加新的标识符。
  2. 选择 App IDs 并点击 Continue
  3. 选择 App 并点击 Continue
  4. 为您的 App ID 输入一个 Description(例如 LibreChat App ID)。
  5. 设置 Bundle ID(例如 com.yourdomain.librechat)。
  6. 点击 Continue,然后点击 Register
  • 图像引用:

  • Create App ID 图 1:创建新的 App ID

  • Select App 图 2:选择 App Identifier

4. 启用 "Sign in with Apple"

  1. 创建 App ID 后,点击它进行编辑。
  2. Capabilities 下,找到并勾选 Sign in with Apple
  3. 点击 Save
  • 图像参考:
  • Enable Sign in with Apple 图 3:启用“使用 Apple 登录”

创建 Services ID

1. 导航至 Identifiers

  • Certificates, Identifiers & Profiles 部分中,点击 Identifiers

2. 创建一个新的 Services ID

  1. 点击 "+" 按钮。
  2. 选择 Services IDs 并点击 Continue
  3. 输入一个 Description(例如 LibreChat Services ID)。
  4. 输入一个 Identifier(例如 com.yourdomain.librechat.services)。
  5. 点击 Continue,然后点击 Register
  • 图像引用:

  • Select Services ID 图 4:选择 Services ID

  • Create Services ID 图 5:创建服务 ID

3. 配置 "Sign in with Apple"

  1. 点击新创建的 Services ID。
  2. Capabilities 下,点击 Sign in with Apple 旁边的 Configure
  3. 输入您的 Domains(例如 your-domain.com)和 Return URLs(例如 https://your-domain.com/oauth/apple/callback)。
  4. 点击 Next,然后点击 Register
  • 图像参考:

  • Configure Sign in with Apple 图 6:为 Services ID 配置“使用 Apple 登录”

  • Web Authentication Configuration 图 7:Web 身份验证配置

  • Web Authentication Configuration 图 8:保存编辑服务 ID 配置


创建密钥

1. 导航至 Keys

  • Certificates, Identifiers & Profiles 部分中,点击 Keys

2. 创建新密钥

  1. 点击 "+" 按钮以添加新密钥。
  2. 输入一个 Key Name(例如 LibreChatSignInWithApple)。
  3. Capabilities 下选择 Sign in with Apple
  4. 点击 Configure 并选择已创建的 App ID(例如 com.yourdomain.librechat),然后点击 Save
  5. 点击 Continue,然后点击 Register
  • 图像引用:

  • Create Key 图 8:创建新密钥

  • Configure Key 图 9:配置带有 App ID 的 Key

  • Register a New Key 图 10:注册密钥

3. 下载私钥

  1. 创建密钥后,点击 Download
  2. 重要提示: 请妥善保存 .p8 文件。您将无法再次下载该文件。
  3. 请注意 Key ID;你需要在 .env 文件中使用它。
  • 图像参考:
  • Download Your Key 图 11:下载私钥

配置 LibreChat

1. 更新 .env 配置

将以下 Apple OAuth2 配置添加到您的 .env 文件中:

DOMAIN_CLIENT=https://your-domain.com # use http://localhost:3080 if not using a custom domain
DOMAIN_SERVER=https://your-domain.com # use http://localhost:3080 if not using a custom domain

# Apple
APPLE_CLIENT_ID=com.yourdomain.librechat.services
APPLE_TEAM_ID=YOUR_TEAM_ID
APPLE_KEY_ID=YOUR_KEY_ID
APPLE_PRIVATE_KEY_PATH=/path/to/AuthKey.p8 # Absolute path to your downloaded .p8 file
APPLE_CALLBACK_URL=/oauth/apple/callback

注意:

  • com.yourdomain.librechat.services 替换为您实际的 Services ID。
  • YOUR_TEAM_IDYOUR_KEY_ID 替换为您 Apple Developer 账户中的相应值。
  • 如果使用 Docker,请确保 .p8 文件在 Docker 容器内可访问,并相应地更新 APPLE_PRIVATE_KEY_PATH

2. 重启 LibreChat

更新 .env 文件后,请重启 LibreChat 以应用更改。

  • 如果使用 Docker:
docker compose up -d

故障排除

如果在设置过程中遇到问题,请考虑以下解决方案:

  • 无效的重定向 URI:

    • 请确保您在 Apple Developer Console 中设置的重定向 URI (https://your-domain.com/oauth/apple/callback) 与您 .env 文件中指定的 URI (APPLE_CALLBACK_URL) 完全一致。
  • 私钥问题:

    • 请验证您的 .p8 文件路径 (APPLE_PRIVATE_KEY_PATH) 是否正确。
    • 确保 LibreChat 对 .p8 文件拥有读取权限。
  • 团队 ID 和密钥 ID 错误:

    • 请仔细核对 .env 文件中的 APPLE_TEAM_IDAPPLE_KEY_ID 是否与您的 Apple Developer Account 中的信息一致。
  • 域名验证失败:

    • 确保验证文件已正确上传到您域名的根目录。
    • 请核实配置过程中输入的域名是否存在拼写错误。
  • Docker 配置问题:

    • 如果使用 Docker,请确认 .p8 文件已正确挂载,并且 APPLE_PRIVATE_KEY_PATH 中的路径在容器内可访问。
  • 检查日志:

    • 检查 LibreChat 日志中是否有与 Apple 身份验证相关的任何错误消息。这可以提供关于可能出现问题的具体见解。

这篇指南怎么样?