mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 11:51:10 +00:00
provide option to extend expiration of jwt token (#1068)
supply optional parameter for `create_jwt` method
This commit is contained in:
committed by
Wan Liuyang
parent
7ee6c41753
commit
86a9d8e973
+6
-3
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user