`Installation.get_repos` needs to differentiate between IAT access and UAT access
get_repos calls /installation/repositories. This is the correct endpoint when the Installation was created from an IAT (or an app, which pygithub handles and upgrades internally).
However if the Installation was obtained via a user access token e.g. AuthenticatedUser.get_installations, then this triggers an HTTP 403 error, the correct endpoint is /user/installations/{installation_id}/repositories.
Sadly one can not even use the repositories_url which is returned as part of the installation object, because it's apparently hardcoded to /installation/repositories (note that it is not currently used by the code anyway, get_repos hard-codes that URL separately).
I can see two places to handle this, both by checking if the auth is AppUserAuth:
- lazily in
get_repos, and switch to the user version - or eagerly in
__init__, after checking forAppAuthcheck forAppUserAuth, and update the_repositories_url(if necessary, in case github eventually fixes this?), and updateget_reposto accessself.repostories_url
Source: PyGithub/PyGithub