Microsoft 凭据(Microsoft credentials)#
你可以使用以下凭据验证以下节点:
🌐 You can use these credentials to authenticate the following nodes:
- Microsoft Dynamics CRM
- Microsoft Excel
- Microsoft 图表安全
- Microsoft OneDrive
- Microsoft Outlook
- Microsoft SharePoint
- Microsoft Teams
- Microsoft Teams 触发器
- Microsoft 待办事项
先决条件(Prerequisites)#
- 创建一个 Microsoft Azure 账户。
- 创建至少一个具有相应服务访问权限的用户账户。
- 如果企业 Microsoft Entra 账户管理用户账户,并且管理员账户已为该用户启用“用户可以同意应用代表他们访问公司数据”的选项(请参见 Microsoft Entra 文档)。
支持的身份验证方法(Supported authentication methods)#
- OAuth2
相关资源(Related resources)#
请参阅以下链接的 Microsoft API 文档,了解有关每个服务 API 的更多信息。
🌐 Refer to the linked Microsoft API documentation below for more information about each service's API:
- Dynamics CRM:Web API
- Excel: Graph API
- 图表安全性:Graph API
- OneDrive:Graph API
- Outlook:Graph API 和 Outlook API
- 团队: Graph API
- 待办事项:Graph API
使用 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.
某些 Microsoft 服务需要额外的 OAuth2 信息。有关这些服务的更多指导,请参阅 特定服务设置。
🌐 Some Microsoft services require extra information for OAuth2. Refer to Service-specific settings for more guidance on those services.
对于自托管用户,从头开始配置 OAuth2 主要分为两个步骤:
🌐 For self-hosted users, there are two main steps to configure OAuth2 from scratch:
按照下面的每个步骤的详细说明操作。有关 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:
- 打开 Microsoft 应用注册门户。
- 选择 注册一个应用。
- 为你的应用输入一个名称。
- 在 支持的账户类型 中,选择 任何组织目录中的账户(Any Azure AD directory - 多租户)和个人 Microsoft 账户(例如 Skype、Xbox)。
- 在 注册应用 中:
- 从你的 n8n 凭证中复制 OAuth 回调 URL。
- 将其粘贴到 重定向 URI(可选) 字段中。
- 选择 选择一个平台 > 网页。
- 选择 注册 以完成创建你的应用。
- 复制 应用(客户端)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:
- 在你的 Microsoft 应用页面上,选择左侧导航中的 证书与密钥。
- 在 客户端密钥 中,选择 + 新建客户端密钥。
- 为你的客户端密钥输入一个描述,例如
n8n credential。 - 选择 添加。
- 复制 值 列中的 秘密。
- 将其粘贴到 n8n 作为 客户端密钥。
- 如果你在 n8n 凭证中看到其他字段,请参考下方的 特定服务设置 以获取填写这些字段的指南。
- 在 n8n 中选择 连接我的账户 以完成连接设置。
- 登录你的 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 OAuth2 凭据支持不同的 Microsoft 云环境。请根据租户的云环境选择适当的终结点:
🌐 The Microsoft OAuth2 credential supports different Microsoft cloud environments. Select the appropriate endpoint based on your tenant's cloud environment:
- 全局:用于标准 Microsoft 365 租户(默认)
- 美国政府:用于 Azure 美国政府(GCC)租户
- 美国政府国防部 (DOD):用于 Azure 美国政府国防部租户
- 中国:适用于由 21Vianet 在中国运营的 Microsoft 365
此设置适用于所有使用 Microsoft 凭据的 Microsoft Graph API 节点,包括:
🌐 This setting applies to all Microsoft Graph API nodes that use Microsoft credentials, including:
- Microsoft Teams
- Microsoft Outlook
- Microsoft Excel
- Microsoft OneDrive
- Microsoft Graph 安全性
- Microsoft To Do
政府云授权网址
如果你正在使用政府云租户,你可能还需要更新凭据中的授权 URL和访问令牌 URL字段,以使用政府云端点。例如:
- 美国政府:使用
https://login.microsoftonline.us/{tenant}/oauth2/v2.0/authorize和https://login.microsoftonline.us/{tenant}/oauth2/v2.0/token - 将
{tenant}替换为你的租户 ID,或对多租户应用使用common
服务特定设置(Service-specific settings)#
以下服务需要额外的 OAuth2 信息:
🌐 The following services require extra information for OAuth2:
动态(Dynamics)#
Dynamics OAuth2 需要有关你的 Dynamics 域和区域的信息。请按照以下额外步骤完成凭证:
🌐 Dynamics OAuth2 requires information about your Dynamics domain and region. Follow these extra steps to complete the credential:
- 请输入你的 Dynamics 域。
- 选择你所在的 Dynamics 数据中心 区域。
有关区域选项和相应 URL 的更多信息,请参阅 Microsoft 数据中心区域文档。
🌐 Refer to the Microsoft Datacenter regions documentation for more information on the region options and corresponding URLs.
Microsoft(常规)(Microsoft (general))#
通用的微软 OAuth2 还要求你为此凭据提供一个以空格分隔的 Scope 列表。
🌐 The general Microsoft OAuth2 also requires you to provide a space-separated list of Scopes for this credential.
请参阅 Microsoft 身份平台中的作用域和权限 以获取可能的作用域列表。
🌐 Refer to Scopes and permissions in the Microsoft identity platform for a list of possible scopes.
Outlook#
Outlook OAuth2 支持凭证访问用户的主邮箱或共享邮箱。默认情况下,凭证将访问用户的主邮箱。要更改此行为:
🌐 Outlook OAuth2 supports the credential accessing a user's primary email inbox or a shared inbox. By default, the credential will access a user's primary email inbox. To change this behavior:
- 打开 使用共享收件箱。
- 输入目标用户的 UPN 或 ID 作为 用户主体名称。
SharePoint#
SharePoint OAuth2 需要关于你的 SharePoint 子域 的信息。
🌐 SharePoint OAuth2 requires information about your SharePoint Subdomain.
要完成凭证,请输入你 SharePoint URL 的 子域 部分。例如,如果你的 SharePoint URL 是 https://tenant123.sharepoint.com,则子域为 tenant123。
🌐 To complete the credential, enter the Subdomain part of your SharePoint URL. For example, if your SharePoint URL is https://tenant123.sharepoint.com, the subdomain is tenant123.
SharePoint 需要以下权限:
🌐 SharePoint requires the following permissions:
应用权限:
🌐 Application permissions:
Sites.Read.AllSites.ReadWrite.All
委托权限:
🌐 Delegated permissions:
SearchConfiguration.Read.AllSearchConfiguration.ReadWrite.All
常见问题(Common issues)#
以下是 Microsoft OAuth2 凭据的已知常见错误和问题。
🌐 Here are the known common errors and issues with Microsoft OAuth2 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.