我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

此版本的 GitHub Enterprise 已停止服务 March 02, 2021. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

排查授权请求错误

为用户获取 OAuth 令牌时,在初始授权请求阶段可能会出现一些错误。

本文内容

应用程序已挂起

如果您设置的 OAuth 应用程序已挂起(由于报告的滥用、垃圾邮件或 API 使用不当),GitHub 将使用以下参数重定向到注册的回调 URL 以总结错误:

http://your-application.com/callback?error=application_suspended
  &error_description=Your+application+has+been+suspended.+Contact+support@github.com.
  &error_uri=/apps/building-integrations/setting-up-and-registering-oauth-apps/troubleshooting-authorization-request-errors/%23application-suspended
  &state=xyz

要解决已挂起应用程序的问题,请联系 您的站点管理员。

重定向 URI 不匹配

如果您提供的 redirect_uri 与您在应用程序中注册的 URL 不匹配,GitHub 将使用以下参数重定向到注册的回调 URL 以总结错误:

http://your-application.com/callback?error=redirect_uri_mismatch
  &error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.
  &error_uri=/apps/building-integrations/setting-up-and-registering-oauth-apps/troubleshooting-authorization-request-errors/%23redirect-uri-mismatch
  &state=xyz

要更正此错误,请提供一个与您注册的 URL 匹配的 redirect_uri,或者忽略此参数以使用在应用程序中注册的默认 URL。

访问被拒绝

如果用户拒绝访问您的应用程序,GitHub 将使用以下参数重定向到注册的回调 URL 以总结错误:

http://your-application.com/callback?error=access_denied
  &error_description=The+user+has+denied+your+application+access.
  &error_uri=/apps/building-integrations/setting-up-and-registering-oauth-apps/troubleshooting-authorization-request-errors/%23access-denied
  &state=xyz

在这方面您无能为力,因为用户可以自由选择不使用您的应用程序。 通常,用户只是关闭窗口或在浏览器中按返回按钮,所以您可能永远不会看到此错误。