#3546·PyGithub

`Installation.get_repos` 需要区分 IAT 访问和 UAT 访问

作者: xmo-odoo创建于 2026年7月7日更新于 2026年7月7日

get_repos 调用了 /installation/repositories。当 Installation 来自 IAT(或应用程序,pygithub 会内部处理和升级)时,这是正确的端点。但是,如果 Installation 通过用户访问令牌(例如 AuthenticatedUser.get_installations)获取,则会触发 HTTP 403 错误,正确的端点是 /user/installations/{installation_id}/repositories。不幸的是,我们甚至无法使用 repositories_url,因为它显然是硬编码为 /installation/repositories(请注意,目前代码中并不使用该 URL,get_repos 单独硬编码了该 URL)。我可以看到两个处理此问题的地方,都通过检查身份是否为 AppUserAuth

  • get_repos 中懒加载,并切换到用户版本

内容来源: PyGithub/PyGithub