provide option to extend expiration of jwt token (#1068)

supply optional parameter for `create_jwt` method
This commit is contained in:
Hamel Husain
2019-03-29 15:37:36 +08:00
committed by Wan Liuyang
parent 7ee6c41753
commit 86a9d8e973
+6 -3
View File
@@ -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(