Skip to content

Microsoft Entra ID 凭据(Microsoft Entra ID credentials)#

你可以使用以下凭据验证以下节点:

🌐 You can use these credentials to authenticate the following nodes:

先决条件(Prerequisites)#

  • 创建 Microsoft Entra ID 账户或订阅。
  • 如果用户账户由企业 Microsoft Entra 账户管理,管理员账户已为该用户启用“用户可以同意应用代表其访问公司数据”选项(参见 Microsoft Entra 文档)。

当你创建 Microsoft Azure 账户时,微软会包含一个免费的 Entra ID 计划。

🌐 Microsoft includes an Entra ID free plan when you create a Microsoft Azure account.

支持的身份验证方法(Supported authentication methods)#

  • OAuth2

有关该服务的更多信息,请参阅 Microsoft Entra ID 的文档

🌐 Refer to Microsoft Entra ID's documentation for more information about the service.

使用 OAuth2(Using OAuth2)#

Note for n8n Cloud users

Cloud users don't need to provide connection details. Select Connect my account to connect through your browser.

对于自托管用户,从头开始配置 OAuth2 主要分为两个步骤:

🌐 For self-hosted users, there are two main steps to configure OAuth2 from scratch:

  1. 在 Microsoft 身份平台上注册应用程序
  2. 为该应用生成客户端密钥

按照下面的每个步骤的详细说明操作。有关 Microsoft OAuth2 网页流程的更多详细信息,请参阅 Microsoft 身份验证和授权基础

🌐 Follow the detailed instructions for each step below. For more detail on the Microsoft OAuth2 web flow, refer to Microsoft authentication and authorization basics.

注册应用(Register an application)#

使用 Microsoft Identity Platform 注册应用:

🌐 Register an application with the Microsoft Identity Platform:

  1. 打开 Microsoft 应用注册门户
  2. 选择 注册一个应用
  3. 为你的应用输入一个名称
  4. 支持的账户类型 中,选择 任何组织目录中的账户(Any Azure AD directory - 多租户)和个人 Microsoft 账户(例如 Skype、Xbox)
  5. 注册应用 中:
    1. 从你的 n8n 凭证中复制 OAuth 回调 URL
    2. 将其粘贴到 重定向 URI(可选) 字段中。
    3. 选择 选择一个平台 > 网页
  6. 选择 注册 以完成创建你的应用。
  7. 复制 应用(客户端)ID 并将其粘贴到 n8n 中作为 客户端 ID

有关更多信息,请参阅 在 Microsoft 身份平台注册应用

🌐 Refer to Register an application with the Microsoft Identity Platform for more information.

生成客户端密钥(Generate a client secret)#

创建应用后,为其生成客户端密钥:

🌐 With your application created, generate a client secret for it:

  1. 在你的 Microsoft 应用页面上,选择左侧导航中的 证书与密钥
  2. 客户端密钥 中,选择 + 新建客户端密钥
  3. 为你的客户端密钥输入一个描述,例如 n8n credential
  4. 选择 添加
  5. 复制 列中的 秘密
  6. 将其粘贴到 n8n 作为 客户端密钥
  7. 在 n8n 中选择 连接我的账户 以完成连接设置。
  8. 登录你的 Microsoft 账户并允许应用访问你的信息。

有关添加客户端密钥的更多信息,请参阅微软的添加凭据

🌐 Refer to Microsoft's Add credentials for more information on adding a client secret.

Microsoft Graph API 基础 URL(Microsoft Graph API Base URL)#

Microsoft Entra ID 凭据扩展了 Microsoft OAuth2 API 凭据,并支持不同的 Microsoft 云环境。请根据你的租户云环境选择合适的端点:

🌐 Microsoft Entra ID credentials extend the Microsoft OAuth2 API credentials and support different Microsoft cloud environments. Select the appropriate endpoint based on your tenant's cloud environment:

  • 全局:用于标准 Microsoft 365 租户(默认)
  • 美国政府:用于 Azure 美国政府(GCC)租户
  • 美国政府国防部 (DOD):用于 Azure 美国政府国防部租户
  • 中国:适用于由 21Vianet 在中国运营的 Microsoft 365

政府云授权网址

如果你正在使用政府云租户,你可能还需要在凭据中更新 Authorization URLAccess Token URL 字段,以使用政府云端点。例如: - 美国政府:使用 https://login.microsoftonline.us/{tenant}/oauth2/v2.0/authorizehttps://login.microsoftonline.us/{tenant}/oauth2/v2.0/token - 将 {tenant} 替换为你的租户 ID,或者对于多租户应用使用 common

设置自定义范围(Setting custom scopes)#

Microsoft Entra ID 凭据默认使用以下范围:

🌐 Microsoft Entra ID credentials use the following scopes by default:

要为你的凭据选择不同的权限范围,请启用 自定义权限范围 开关并编辑 启用的权限范围 列表。请记住,某些功能在权限范围更受限制的情况下可能无法正常工作。

🌐 To select different scopes for your credentials, enable the Custom Scopes slider and edit the Enabled Scopes list. Keep in mind that some features may not work as expected with more restrictive scopes.

常见问题(Common issues)#

以下是 Microsoft Entra 凭据的已知常见错误和问题。

🌐 Here are the known common errors and issues with Microsoft Entra credentials.

Need admin approval#

When attempting to add credentials for a Microsoft360 or Microsoft Entra account, users may see a message when following the procedure that this action requires admin approval.

This message will appear when the account attempting to grant permissions for the credential is managed by a Microsoft Entra. In order to issue the credential, the administrator account needs to grant permission to the user (or "tenant") for that application.

The procedure for this is covered in the Microsoft Entra documentation.