Skip to main content

此版本的 GitHub Enterprise Server 将于以下日期停止服务 2026-06-02. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

为 GitHub 应用生成安装访问令牌

了解如何为 GitHub App 生成安装访问令牌。

关于安装访问令牌的相关信息

若要以应用安装形式进行身份验证,必须生成安装访问令牌。 有关作为 GitHub 应用安装进行身份验证的详细信息,请参阅 作为 GitHub 应用安装进行身份验证

注意

可以使用 GitHub 的 Octokit SDK 以应用形式进行身份验证,而不是生成安装访问令牌。 SDK 将负责为你生成安装访问令牌,并在令牌过期后重新生成该令牌。 有关作为 GitHub 应用安装进行身份验证的详细信息,请参阅 作为 GitHub 应用安装进行身份验证

应确保安装访问令牌的安全。 有关详细信息,请参阅“创建GitHub应用的最佳做法”。

生成安装访问令牌

注意

Starting April 27, 2026, GitHub began a staged rollout of a stateless format (ghs_APPID_JWT) to all newly minted GitHub App installation tokens, making them more performant and improving the reliability of our API surface. If your application expects or relies on installation tokens being exactly 40 characters long, it may not handle this new token format correctly. You can now validate your apps and workflows using a temporary request header that lets you enable the token format on demand. For more information about the temporary header, see the GitHub blog.