Skip to content

GitHub 凭据#

¥GitHub credentials

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

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

¥GitHub Trigger

¥GitHub Document Loader: this node doesn't support OAuth.

先决条件#

¥Prerequisites

创建 GitHub 账户。

¥Create a GitHub account.

支持的身份验证方法#

¥Supported authentication methods

  • API 访问令牌:使用此方法与任何 GitHub 节点一起使用。

¥API access token: Use this method with any GitHub nodes.

¥OAuth2: Use this method with GitHub and GitHub Trigger nodes only; don't use with 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:

  1. 生成 GitHub 个人访问令牌

¥Generate a GitHub personal access token. 2. 设置凭据

¥Set up the credential.

请参阅以下各节以获取详细说明。

¥Refer to the sections below for detailed instructions.

生成个人访问令牌#

¥Generate personal access token

Recommended access token type

n8n 建议使用个人访问令牌(经典)。GitHub 的细粒度个人访问令牌仍处于测试阶段,无法访问所有端点。

¥n8n recommends using a personal access token (classic). GitHub's fine-grained personal access tokens are still in beta and can't access all endpoints.

生成个人访问令牌:

¥To generate your personal access token:

  1. 如果你尚未验证你的电子邮件地址,请使用 GitHub 进行验证。有关更多信息,请参阅 验证你的电子邮件地址

¥If you haven't done so already, verify your email address with GitHub. Refer to Verifying your email address for more information. 2. 打开你的 GitHub 个人资料 设置

¥Open your GitHub profile Settings. 3. 在左侧导航栏中,选择“开发者设置”。

¥In the left navigation, select Developer settings. 4. 在左侧导航栏的“个人访问令牌”下,选择“令牌(经典)”。

¥In the left navigation, under Personal access tokens, select Tokens (classic). 5. 选择“生成新令牌”>“生成新令牌(经典)”。

¥Select Generate new token > Generate new token (classic). 6. 在“备注”字段中输入令牌的描述性名称,例如 n8n integration

¥Enter a descriptive name for your token in the Note field, like n8n integration. 7. 选择令牌的过期时间,或选择“无过期时间”。

¥Select the Expiration you'd like for the token, or select No expiration. 8. 为你的令牌选择“范围”。对于大多数 n8n GitHub 节点,请添加 repo 范围。

¥Select Scopes for your token. For most of the n8n GitHub nodes, add the repo scope.

  • 未分配权限的令牌只能访问公共信息。

    ¥A token without assigned scopes can only access public information.

  • 请参考

    ¥Refer to 9. 选择“生成令牌”。

¥Select Generate token. 10. 复制令牌。

1
¥Copy the token.

有关更多信息,请参阅 创建个人访问令牌(经典)。请参阅 OAuth 应用的范围,了解有关 GitHub 作用域的更多信息。

¥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:

  1. 如果你未使用 GitHub Enterprise Server,请勿更改 GitHub 服务器 URL。

¥If you aren't using GitHub Enterprise Server, don't change the GitHub server URL.

  • 如果你使用的是 GitHub Enterprise Server,请将 GitHub 服务器地址更新为你的服务器 URL。

    ¥If you're using GitHub Enterprise Server, update GitHub server to match the URL for your server. 2. 请输入你在 GitHub 个人资料中显示的用户名。

¥Enter your User name as it appears in your GitHub profile. 3. 输入你上面生成的访问令牌。

¥Enter the Access Token you generated above.

使用 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:

  1. 打开你的 GitHub 个人资料 设置

¥Open your GitHub profile Settings. 2. 在左侧导航栏中,选择“开发者设置”。

¥In the left navigation, select Developer settings. 3. 在左侧导航栏中,选择“OAuth 应用”。

¥In the left navigation, select OAuth apps. 4. 选择“新建 OAuth 应用”。

¥Select New OAuth App.

  • 如果你之前没有创建过应用,则可能会看到“注册新应用”的提示。选择它。

    ¥If you haven't created an app before, you may see Register a new application instead. Select it. 5. 输入应用名称,例如 n8n integration

¥Enter an Application name, like n8n integration. 6. 输入你的应用网站的主页 URL。

¥Enter the Homepage URL for your app's website. 7. 你可以根据需要添加可选的应用描述,GitHub 会将其显示给终端用户。

¥If you'd like, add the optional Application description, which GitHub displays to end-users. 8. 从 n8n 复制 OAuth 重定向 URL,并将其粘贴到 GitHub 授权回调 URL 中。

¥From n8n, copy the OAuth Redirect URL and paste it into the GitHub Authorization callback URL. 9. 选择“注册应用”。

¥Select Register application. 10. 复制生成的客户端 ID 和客户端密钥,并将其添加到你的 n8n 凭据中。

1
¥Copy the **Client ID** and **Client Secret** this generates and add them to your n8n credential.

有关授权过程的更多信息,请参阅 GitHub 授权 OAuth 应用文档

¥Refer to the GitHub Authorizing OAuth apps documentation for more information on the authorization process.