GitHub 凭据(GitHub credentials)#
你可以使用以下凭据验证以下节点:
🌐 You can use these credentials to authenticate the following nodes:
- GitHub
- GitHub 触发器
- GitHub 文档加载器:该节点不支持 OAuth。
先决条件(Prerequisites)#
创建一个 GitHub 账户。
🌐 Create a GitHub account.
支持的身份验证方法(Supported authentication methods)#
- API 访问令牌:在任何 GitHub 节点中使用此方法。
- OAuth2:仅在 GitHub 和 GitHub Trigger 节点上使用此方法;不要在 GitHub Document Loader 上使用。
相关资源(Related resources)#
有关该服务的更多信息,请参阅GitHub 的 API 文档。
🌐 Refer to GitHub's API documentation for more information about the service.
使用 API 访问令牌(Using API access token)#
要配置此凭据,你需要一个 GitHub 账户。
🌐 To configure this credential, you'll need a GitHub account.
设置此凭据分为两个步骤:
🌐 There are two steps to setting up this credential:
请参阅以下各节以获取详细说明。
🌐 Refer to the sections below for detailed instructions.
生成个人访问令牌(Generate personal access token)#
推荐的访问令牌类型
n8n 建议使用个人访问令牌(经典)。GitHub 的细粒度个人访问令牌仍处于测试阶段,无法访问所有端点。
生成个人访问令牌:
🌐 To generate your personal access token:
- 如果你尚未完成此操作,请通过 GitHub 验证你的电子邮件地址。有关更多信息,请参阅验证你的电子邮件地址。
- 打开你的 GitHub 个人资料 设置。
- 在左侧导航中,选择 开发者设置。
- 在左侧导航栏中,进入 个人访问令牌 下,选择 令牌(经典)。
- 选择 生成新令牌 > 生成新令牌(经典)。
- 在 Note 字段中输入你的令牌的描述性名称,例如
n8n integration。 - 选择你希望为令牌设置的到期时间,或选择永不过期。
- 为你的令牌选择范围。对于大多数 n8n GitHub 节点,请添加
repo范围。- 未分配权限的令牌只能访问公共信息。
- 请参考
- 选择 生成令牌。10. 复制令牌。
有关详细信息,请参阅创建个人访问令牌(经典)。有关 GitHub 作用域的更多信息,请参阅OAuth 应用的作用域。
🌐 Refer to Creating a personal access token (classic) for more information. Refer to Scopes for OAuth apps for more information on GitHub scopes.
设置凭据(Set up the credential)#
然后,在你的 n8n 凭据中:
🌐 Then, in your n8n credential:
- 如果你没有使用 GitHub Enterprise Server,请不要更改 GitHub 服务器 URL。
- 如果你正在使用 GitHub Enterprise Server,请更新 GitHub 服务器 以匹配你的服务器 URL。
- 输入与你的 GitHub 个人资料中显示的相同的用户名。
- 输入你上面生成的访问令牌。
使用 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.
如果你在自托管 n8n,请创建一个新的 GitHub OAuth 应用:
🌐 If you're self-hosting n8n, create a new GitHub OAuth app:
- 打开你的 GitHub 个人资料 设置。
- 在左侧导航中,选择 开发者设置。
- 在左侧导航中,选择 OAuth 应用。
- 选择 新建 OAuth 应用。
- 如果你以前没有创建过应用,你可能会看到 注册新应用。请选择它。
- 输入一个应用名称,例如
n8n integration。 - 请输入你应用网站的 首页网址。
- 如果你愿意,可以添加可选的应用描述,GitHub 会显示给终端用户。
- 在 n8n 中,复制 OAuth 重定向 URL 并将其粘贴到 GitHub 的 授权回调 URL 中。
- 选择 注册应用。10. 复制生成的 客户端 ID 和 客户端密钥,并将它们添加到你的 n8n 凭证中。
有关授权过程的更多信息,请参阅 GitHub 授权 OAuth 应用文档。
🌐 Refer to the GitHub Authorizing OAuth apps documentation for more information on the authorization process.