mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Add authentication classes, move auth logic there (#2528)
This adds argument `auth` and deprecates `login_or_token`, `password`, `jwt`, and `app_auth` arguments of `github.Github`. This adds argument `auth` and deprecates `integration_id`, `private_key` of `github.GithubIntegration`. This deprecates the `create_jwt` method of `github.GithubIntegration`, replaced by `github.Auth.AppAuth.create_jwt`.
This commit is contained in:
+10
-15
@@ -23,13 +23,13 @@
|
||||
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
import deprecated
|
||||
|
||||
class AppAuthentication:
|
||||
app_id: Union[int, str]
|
||||
private_key: str
|
||||
installation_id: int
|
||||
token_permissions: Optional[Dict[str, str]]
|
||||
from github.Auth import AppAuth, AppInstallationAuth
|
||||
|
||||
|
||||
@deprecated.deprecated("Use app.Auth.AppInstallationAuth instead")
|
||||
class AppAuthentication(AppInstallationAuth):
|
||||
def __init__(
|
||||
self,
|
||||
app_id: Union[int, str],
|
||||
@@ -37,13 +37,8 @@ class AppAuthentication:
|
||||
installation_id: int,
|
||||
token_permissions: Optional[Dict[str, str]] = None,
|
||||
):
|
||||
assert isinstance(app_id, (int, str)), app_id
|
||||
assert isinstance(private_key, str)
|
||||
assert isinstance(installation_id, int), installation_id
|
||||
assert token_permissions is None or isinstance(
|
||||
token_permissions, dict
|
||||
), token_permissions
|
||||
self.app_id = app_id
|
||||
self.private_key = private_key
|
||||
self.installation_id = installation_id
|
||||
self.token_permissions = token_permissions
|
||||
super().__init__(
|
||||
app_auth=AppAuth(app_id, private_key),
|
||||
installation_id=installation_id,
|
||||
token_permissions=token_permissions,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user