This class is used to authenticate as a GitHub App Installation. https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation
| 311 | |
| 312 | |
| 313 | class AppInstallationAuth(Auth, WithRequester["AppInstallationAuth"]): |
| 314 | """ |
| 315 | This class is used to authenticate as a GitHub App Installation. |
| 316 | |
| 317 | https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation |
| 318 | |
| 319 | """ |
| 320 | |
| 321 | # used to fetch live access token when calling self.token |
| 322 | __integration: GithubIntegration | None = None |
| 323 | __installation_authorization: InstallationAuthorization | None = None |
| 324 | |
| 325 | def __init__( |
| 326 | self, |
| 327 | app_auth: AppAuth, |
| 328 | installation_id: int, |
| 329 | token_permissions: dict[str, str] | None = None, |
| 330 | requester: Requester | None = None, |
| 331 | ): |
| 332 | super().__init__() |
| 333 | |
| 334 | assert isinstance(app_auth, AppAuth), app_auth |
| 335 | assert isinstance(installation_id, int), installation_id |
| 336 | assert token_permissions is None or isinstance(token_permissions, dict), token_permissions |
| 337 | assert requester is None or isinstance(requester, Requester), requester |
| 338 | |
| 339 | self._app_auth = app_auth |
| 340 | self._installation_id = installation_id |
| 341 | self._token_permissions = token_permissions |
| 342 | |
| 343 | if requester is not None: |
| 344 | self.withRequester(requester) |
| 345 | |
| 346 | def withRequester(self, requester: Requester) -> AppInstallationAuth: |
| 347 | assert isinstance(requester, Requester), requester |
| 348 | super().withRequester(requester.withAuth(self._app_auth)) |
| 349 | |
| 350 | # imported here to avoid circular import |
| 351 | from github.GithubIntegration import GithubIntegration |
| 352 | |
| 353 | self.__integration = GithubIntegration(**self.requester.kwargs) |
| 354 | |
| 355 | return self |
| 356 | |
| 357 | @property |
| 358 | def app_id(self) -> int | str: |
| 359 | return self._app_auth.app_id |
| 360 | |
| 361 | @property |
| 362 | def installation_id(self) -> int: |
| 363 | return self._installation_id |
| 364 | |
| 365 | @property |
| 366 | def token_permissions(self) -> dict[str, str] | None: |
| 367 | return self._token_permissions |
| 368 | |
| 369 | @property |
| 370 | def token_type(self) -> str: |
no outgoing calls
no test coverage detected
searching dependent graphs…