This class is used to authenticate as a GitHub App on behalf of a user. https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user
| 395 | |
| 396 | |
| 397 | class AppUserAuth(Auth, WithRequester["AppUserAuth"]): |
| 398 | """ |
| 399 | This class is used to authenticate as a GitHub App on behalf of a user. |
| 400 | |
| 401 | https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user |
| 402 | |
| 403 | """ |
| 404 | |
| 405 | _client_id: str |
| 406 | _client_secret: str |
| 407 | _token: str |
| 408 | _type: str |
| 409 | _scope: str | None |
| 410 | _expires_at: datetime | None |
| 411 | _refresh_token: str | None |
| 412 | _refresh_expires_at: datetime | None |
| 413 | |
| 414 | # imported here to avoid circular import |
| 415 | from github.ApplicationOAuth import ApplicationOAuth |
| 416 | |
| 417 | __app: ApplicationOAuth |
| 418 | |
| 419 | def __init__( |
| 420 | self, |
| 421 | client_id: str, |
| 422 | client_secret: str, |
| 423 | token: str, |
| 424 | token_type: str | None = None, |
| 425 | expires_at: datetime | None = None, |
| 426 | refresh_token: str | None = None, |
| 427 | refresh_expires_at: datetime | None = None, |
| 428 | requester: Requester | None = None, |
| 429 | ) -> None: |
| 430 | super().__init__() |
| 431 | |
| 432 | assert isinstance(client_id, str) and len(client_id) > 0 |
| 433 | assert isinstance(client_secret, str) and len(client_secret) > 0 |
| 434 | assert isinstance(token, str) and len(token) > 0 |
| 435 | assert token_type is None or isinstance(token_type, str) and len(token_type) > 0, token_type |
| 436 | assert expires_at is None or isinstance(expires_at, datetime), expires_at |
| 437 | assert refresh_token is None or isinstance(refresh_token, str) and len(refresh_token) > 0 |
| 438 | assert refresh_expires_at is None or isinstance(refresh_expires_at, datetime), refresh_expires_at |
| 439 | assert requester is None or isinstance(requester, Requester), requester |
| 440 | |
| 441 | self._client_id = client_id |
| 442 | self._client_secret = client_secret |
| 443 | self._token = token |
| 444 | self._type = token_type or "bearer" |
| 445 | self._expires_at = expires_at |
| 446 | self._refresh_token = refresh_token |
| 447 | self._refresh_expires_at = refresh_expires_at |
| 448 | |
| 449 | if requester is not None: |
| 450 | self.withRequester(requester) |
| 451 | |
| 452 | @property |
| 453 | def token_type(self) -> str: |
| 454 | return self._type |
no outgoing calls
no test coverage detected
searching dependent graphs…