|
21 | 21 | class Authentication(metaclass=ABCMeta):
|
22 | 22 | def __init__(self, app_id: int, installation_id: int, client_secret, *, iat: int = 30, exp: int = 30):
|
23 | 23 | self.installation_id = installation_id
|
24 |
| - self.endpoint = 'https://api.github.com/installations/{}/access_tokens'.format( |
| 24 | + self.endpoint = 'https://api.github.com/app/installations/{}/access_tokens'.format( |
25 | 25 | self.installation_id)
|
26 | 26 | self.algorithm = "RS256"
|
27 | 27 | self.app_id = app_id
|
@@ -247,9 +247,9 @@ def is_authorization(self, *, _jwt: str = None, client_public: str = None) -> bo
|
247 | 247 | _jwt = self.gen_jwt()
|
248 | 248 | if client_public is None:
|
249 | 249 | client_public = self.gen_pubkey()
|
| 250 | + |
250 | 251 | try:
|
251 |
| - decoded_jwt = jwt.decode(_jwt, key=client_public, |
252 |
| - audience=self.endpoint, algorithms=self.algorithm) |
| 252 | + decoded_jwt = jwt.decode(_jwt, key=client_public, algorithms=self.algorithm) |
253 | 253 | if decoded_jwt['iss'] == self.app_id:
|
254 | 254 | return True
|
255 | 255 | except:
|
@@ -278,7 +278,7 @@ def get_access_token_response(self, *, _jwt: bytes = None, **kwargs) -> Optional
|
278 | 278 | _jwt = self.gen_jwt()
|
279 | 279 |
|
280 | 280 | headers = {
|
281 |
| - 'Accept': 'application/vnd.github.machine-man-preview+json', |
| 281 | + 'Accept': 'application/vnd.github.v3+json', |
282 | 282 | 'Authorization': 'Bearer {}'.format(_jwt),
|
283 | 283 | }
|
284 | 284 | if self.is_authorization():
|
@@ -316,7 +316,7 @@ def get_access_token(self, *, access_token_response: Optional[Union[list, dict]]
|
316 | 316 | """
|
317 | 317 | if access_token_response is None:
|
318 | 318 | access_token_response = self.get_access_token_response()
|
319 |
| - return access_token_response['access_token'] |
| 319 | + return access_token_response["token"] |
320 | 320 |
|
321 | 321 | def get_usage(self) -> None:
|
322 | 322 | return None
|
0 commit comments