MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / create_jwt

Method create_jwt

github/Auth.py:270–292  ·  view source on GitHub ↗

Create a signed JWT https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app :return string: jwt

(self, expiration: int | None = None)

Source from the content-addressed store, hash-verified

268 return AppInstallationAuth(self, installation_id, token_permissions, requester)
269
270 def create_jwt(self, expiration: int | None = None) -> str:
271 """
272 Create a signed JWT
273 https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app
274
275 :return string: jwt
276 """
277 if expiration is not None:
278 assert isinstance(expiration, int), expiration
279 assert Consts.MIN_JWT_EXPIRY <= expiration <= Consts.MAX_JWT_EXPIRY, expiration
280
281 now = int(time.time())
282 payload = {
283 "iat": now + self._jwt_issued_at,
284 "exp": now + (expiration if expiration is not None else self._jwt_expiry),
285 "iss": self._app_id,
286 }
287 assert self._sign_func is not None
288 encrypted = self._sign_func(payload)
289
290 if isinstance(encrypted, bytes):
291 return encrypted.decode("utf-8")
292 return encrypted
293
294
295class AppAuthToken(JWT):

Callers 3

tokenMethod · 0.95
testCreateJWTMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected