mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Fix auth issues with Installation.get_repos (#2547)
This commit is contained in:
@@ -35,6 +35,7 @@ import github.PaginatedList
|
||||
import github.Plan
|
||||
import github.Repository
|
||||
import github.UserKey
|
||||
from github.Auth import AppAuth
|
||||
|
||||
from . import Consts
|
||||
|
||||
@@ -46,6 +47,16 @@ class Installation(github.GithubObject.NonCompletableGithubObject):
|
||||
This class represents Installations. The reference can be found here https://docs.github.com/en/rest/reference/apps#installations
|
||||
"""
|
||||
|
||||
def __init__(self, requester, headers, attributes, completed):
|
||||
super().__init__(requester, headers, attributes, completed)
|
||||
|
||||
auth = self._requester.auth if self._requester is not None else None
|
||||
# Usually, an Installation is created from a Requester with App authentication
|
||||
if isinstance(auth, AppAuth):
|
||||
# But the installation has to authenticate as an installation (e.g. for get_repos())
|
||||
auth = auth.get_installation_auth(self.id, requester=self._requester)
|
||||
self._requester = self._requester.withAuth(auth)
|
||||
|
||||
def __repr__(self):
|
||||
return self.get__repr__({"id": self._id.value})
|
||||
|
||||
|
||||
@@ -343,6 +343,10 @@ class Requester:
|
||||
def base_url(self):
|
||||
return self.__base_url
|
||||
|
||||
@property
|
||||
def auth(self):
|
||||
return self.__auth
|
||||
|
||||
def withAuth(self, auth):
|
||||
"""
|
||||
Create a new requester instance with identical configuration but the given authentication method.
|
||||
|
||||
@@ -141,6 +141,8 @@ class Requester:
|
||||
) -> None: ...
|
||||
@property
|
||||
def base_url(self) -> str: ...
|
||||
@property
|
||||
def auth(self) -> Optional[Auth]: ...
|
||||
def withAuth(self, auth: Optional[Auth]) -> Requester: ...
|
||||
def _initializeDebugFeature(self) -> None: ...
|
||||
def check_me(self, obj: GithubObject) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user