Salesforce 凭据#
¥Salesforce credentials
你可以使用以下凭据验证以下节点:
¥You can use these credentials to authenticate the following nodes:
支持的身份验证方法#
¥Supported authentication methods
-
JWT
-
OAuth2
相关资源#
¥Related resources
有关服务的更多信息,请参阅 Salesforce 开发者文档。
¥Refer to Salesforce's developer documentation for more information about the service.
使用 JWT#
¥Using JWT
要配置此凭据,你需要一个 Salesforce 账户以及:
¥To configure this credential, you'll need a Salesforce account and:
- 你的环境类型(生产环境或沙盒环境)。
¥Your Environment Type (Production or Sandbox)
- 客户端 ID:创建已连接应用时生成。
¥A Client ID: Generated when you create a connected app.
- 你的 Salesforce 用户名
¥Your Salesforce Username
- 自签名数字证书的私钥
¥A Private Key for a self-signed digital certificate
要进行设置,首先你需要创建私钥和证书,然后创建一个关联的应用:
¥To set things up, first you'll create a private key and certificate, then a connected app:
- 在 n8n 中,选择连接的环境类型。请从“生产环境”或“沙盒环境”中选择最能描述你当前环境的选项。
¥In n8n, select the Environment Type for your connection. Choose the option that best describes your environment from Production or Sandbox. 2. 请输入你的 Salesforce 用户名。
¥Enter your Salesforce Username. 3. 登录你的 Salesforce 组织。
¥Log in to your org in Salesforce. 4. 你需要由证书颁发机构颁发的私钥和证书。使用你自己的密钥/证书,或使用 OpenSSL 创建密钥和自签名数字证书。请参阅 Salesforce 创建私钥和自签名数字证书文档 文档,了解如何创建你自己的密钥和证书。
¥You'll need a private key and certificate issued by a certification authority. Use your own key/cert or use OpenSSL to create a key and a self-signed digital certificate. Refer to the Salesforce Create a Private Key and Self-Signed Digital Certificate documentation for instructions on creating your own key and certificate.
5. 在 Salesforce 设置中,在“快速查找”框中输入 App Manager,然后选择“应用管理器”。
¥From Setup in Salesforce, enter App Manager in the Quick Find box, then select App Manager.
6. 在“应用管理器”页面上,选择“新建连接应用”。
¥On the App Manager page, select New Connected App. 7. 输入已连接应用的必要基本信息,包括名称和联系邮箱地址。有关更多信息,请参阅 Salesforce 的 配置基本连接应用设置 文档。
¥Enter the required Basic Info for your connected app, including a Name and Contact Email address. Refer to Salesforce's Configure Basic Connected App Settings documentation for more information. 8. 选中“启用 OAuth 设置”复选框。
¥Check the box to Enable OAuth Settings.
9. 对于“回调 URL”,请输入 http://localhost:1717/OauthRedirect。
¥For the Callback URL, enter http://localhost:1717/OauthRedirect.
10. 选中“使用数字签名”复选框。
1 | |
-
选择“选择文件”并上传包含你的数字证书的文件,例如
server.crt。¥Select Choose File and upload the file that contains your digital certificate, such as
server.crt. 12. 添加以下 OAuth 权限范围:¥Add these OAuth scopes:
- 完全访问权限 (full)
¥Full access (full)
- 随时执行请求(刷新令牌、离线访问)。
¥Perform requests at any time (refresh_token, offline_access) 13. 选择“保存,然后继续”。“管理已连接的应用”页面应该会打开你刚刚创建的应用。
¥Select Save, then Continue. The Manage Connected Apps page should open to the app you just created. 14. 在“API(启用 OAuth 设置)”部分,选择“管理消费者详细信息”。
¥In the API (Enable OAuth Settings) section, select Manage Consumer Details. 15. 复制消费者密钥并将其作为客户端 ID 添加到你的 n8n 凭据中。
¥Copy the Consumer Key and add it to your n8n credential as the Client ID. 16. 在“私钥”字段中输入 n8n 中私钥文件的内容。
¥Enter the contents of the private key file in n8n as Private Key.
- 使用 n8n 中的多行编辑器。
¥Use the multi-line editor in n8n.
- 以标准 PEM 密钥格式输入私钥:
¥Enter the private key in standard PEM key format:
1 2 3
-----BEGIN PRIVATE KEY----- KEY DATA GOES HERE -----END PRIVATE KEY-----
以下步骤是 n8n 端所需的操作。Salesforce 还建议设置刷新令牌策略、会话策略和 OAuth 策略:
¥These steps are what's required on the n8n side. Salesforce recommends setting refresh token policies, session policies, and OAuth policies too:
-
在 Salesforce 中,选择“返回管理已连接的应用”。
¥In Salesforce, select Back to Manage Connected Apps. 15. 选择“管理”。
¥Select Manage. 16. 选择“编辑策略”。
¥Select Edit Policies. 17. 检查刷新令牌策略字段。Salesforce 建议将刷新令牌的过期时间设置为 90 天。
¥Review the Refresh Token Policy field. Salesforce recommends using expire refresh token after 90 days. 18. 在“会话策略”部分,Salesforce 建议将超时值设置为 15 分钟。
¥In the Session Policies section, Salesforce recommends setting Timeout Value to 15 minutes. 19. 在“OAuth 策略”部分,对于“允许的用户”,选择“管理员批准的用户已预先授权”,然后选择“确定”。
¥In the OAuth Policies section, select Admin approved users are pre-authorized for permitted users for Permitted Users, and select OK. 20. 选择“保存”。
¥Select Save. 21. 选择“管理配置文件”,选择已预先授权使用此连接应用的配置文件,然后选择“保存”。
¥Select Manage Profiles, select the profiles that are pre-authorized to use this connected app, and select Save. 22. 选择“管理权限集”以选择权限集。如有必要,创建权限集。
¥Select Manage Permission Sets to select the permission sets. Create permission sets if necessary.
有关更多信息,请参阅 Salesforce 的 在你的组织中创建互联应用 文档。
¥Refer to Salesforce's Create a Connected App in Your Org documentation for more information.
使用 OAuth2#
¥Using OAuth2
要配置此凭据,你需要一个 Salesforce 账户。
¥To configure this credential, you'll need a Salesforce account.
Note for n8n Cloud users
Cloud users don't need to provide connection details. Select Connect my account to connect through your browser.
云端和托管用户需要选择环境类型。选择生产环境或沙盒环境。
¥Cloud and hosted users will need to select your Environment Type. Choose between Production and Sandbox.
如果你使用的是 self-hosting n8n,则需要通过创建一个已连接的应用来从头开始配置 OAuth2:
¥If you're self-hosting n8n, you'll need to configure OAuth2 from scratch by creating a connected app:
- 在 n8n 中,选择连接的环境类型。请从“生产环境”或“沙盒环境”中选择最能描述你当前环境的选项。
¥In n8n, select the Environment Type for your connection. Choose the option that best describes your environment from Production or Sandbox. 2. 请输入你的 Salesforce 用户名。
¥Enter your Salesforce Username. 3. 登录你的 Salesforce 组织。
¥Log in to your org in Salesforce.
4. 在 Salesforce 设置中,在“快速查找”框中输入 App Manager,然后选择“应用管理器”。
¥From Setup in Salesforce, enter App Manager in the Quick Find box, then select App Manager.
5. 在“应用管理器”页面上,选择“新建连接应用”。
¥On the App Manager page, select New Connected App. 6. 输入已连接应用的必要基本信息,包括名称和联系邮箱地址。有关更多信息,请参阅 Salesforce 的 配置基本连接应用设置 文档。
¥Enter the required Basic Info for your connected app, including a Name and Contact Email address. Refer to Salesforce's Configure Basic Connected App Settings documentation for more information. 7. 选中“启用 OAuth 设置”复选框。
¥Check the box to Enable OAuth Settings.
8. 对于“回调 URL”,请输入 http://localhost:1717/OauthRedirect。
¥For the Callback URL, enter http://localhost:1717/OauthRedirect.
9. 添加以下 OAuth 权限范围:
¥Add these OAuth scopes:
-
完全访问权限 (full)
¥Full access (full)
-
随时执行请求(刷新令牌、离线访问)。
¥Perform requests at any time (refresh_token, offline_access) 10. 请确保以下设置未选中:
¥Make sure the following settings are unchecked:
- 支持的授权流程需要代码交换验证密钥 (PKCE) 扩展
¥Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows
- Web 服务器流程需要密钥
¥Require Secret for Web Server Flow
- 刷新令牌流程需要密钥
¥Require Secret for Refresh Token Flow 11. 选择“保存,然后继续”。“管理已连接的应用”页面应该会打开你刚刚创建的应用。
¥Select Save, then Continue. The Manage Connected Apps page should open to the app you just created. 12. 在“API(启用 OAuth 设置)”部分,选择“管理消费者详细信息”。
¥In the API (Enable OAuth Settings) section, select Manage Consumer Details. 13. 复制消费者密钥并将其作为客户端 ID 添加到你的 n8n 凭据中。
¥Copy the Consumer Key and add it to your n8n credential as the Client ID. 14. 复制消费者密钥并将其作为客户端密钥添加到你的 n8n 凭据中。
¥Copy the Consumer Secret and add it to your n8n credential as the Client Secret.
以下步骤是 n8n 端所需的操作。Salesforce 还建议设置刷新令牌策略和会话策略:
¥These steps are what's required on the n8n side. Salesforce recommends setting refresh token policies and session policies, too:
-
在 Salesforce 中,选择“返回管理已连接的应用”。
¥In Salesforce, select Back to Manage Connected Apps. 15. 选择“管理”。
¥Select Manage. 16. 选择“编辑策略”。
¥Select Edit Policies. 17. 检查刷新令牌策略字段。Salesforce 建议将刷新令牌的过期时间设置为 90 天。
¥Review the Refresh Token Policy field. Salesforce recommends using expire refresh token after 90 days. 18. 在“会话策略”部分,Salesforce 建议将超时值设置为 15 分钟。
¥In the Session Policies section, Salesforce recommends setting Timeout Value to 15 minutes.
有关更多信息,请参阅 Salesforce 的 在你的组织中创建互联应用 文档。
¥Refer to Salesforce's Create a Connected App in Your Org documentation for more information.
常见问题#
¥Common issues
从 n8n Cloud 使用 Salesforce 进行身份验证时出现连接问题#
¥Connection issues when authenticating with Salesforce from n8n Cloud
如果你在使用 n8n Cloud 进行 Salesforce 身份验证时遇到连接问题,你可能需要在 Salesforce 用户配置文件中启用特定的系统权限:
¥If you encounter connection issues when authenticating with Salesforce from n8n Cloud, you might need to enable a specific system permission in your Salesforce user profiles:
- 在 Salesforce 中,转到“设置”。
¥In Salesforce, go to Setup.
2. 在“快速查找”框中,搜索 Profiles。
¥In the Quick Find box, search for Profiles.
3. 选择连接到 n8n 的用户使用的配置文件(例如,系统管理员或相关配置文件)。
¥Select the profile used by the user connecting to n8n (for example, System Administrator or the relevant profile). 4. 点击“编辑”,或使用新的“配置文件”界面(如果可用)。
¥Click Edit or use the new Profile interface if it's available. 5. 找到“管理权限”部分。
¥Locate the Administrative Permissions section. 6. 启用“允许非管理员用户访问已连接的应用”复选框。根据你的 Salesforce 语言或翻译,此复选框也可能显示为“批准已连接但未安装的应用”。
¥Enable the checkbox for Approve Connected Apps for Non-Admins. This checkbox might also appear as Approve apps connected not installed depending on your Salesforce language or translation. 7. 点击“保存”。
¥Click Save.
此权限默认情况下未启用,即使是管理员配置文件也未启用,必须手动激活。如果没有此权限,你在尝试将 n8n 连接到 Salesforce 时可能会遇到身份验证失败。
¥This permission is not enabled by default, even for administrator profiles, and must be manually activated. Without this permission, you might experience authentication failures when trying to connect n8n to Salesforce.