From 86a9d8e97320313fe03d8422b540dd3950ca7d9c Mon Sep 17 00:00:00 2001 From: Hamel Husain Date: Fri, 29 Mar 2019 00:37:36 -0700 Subject: [PATCH] provide option to extend expiration of jwt token (#1068) supply optional parameter for `create_jwt` method --- github/MainClass.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/github/MainClass.py b/github/MainClass.py index 92f79870..e9038198 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -742,15 +742,18 @@ class GithubIntegration(object): self.integration_id = integration_id self.private_key = private_key - def create_jwt(self): + def create_jwt(self, expiration=60): """ - Creates a signed JWT, valid for 60 seconds. + Creates a signed JWT, valid for 60 seconds by default. + The expiration can be extended beyond this, to a maximum of 600 seconds. + + :param expiration: int :return: """ now = int(time.time()) payload = { "iat": now, - "exp": now + 60, + "exp": now + expiration, "iss": self.integration_id } encrypted = jwt.encode(