Skip to content

Commit 7bc4517

Browse files
authored
Merge pull request #21 from trz42/fix-renewal-of-access-token
Fixing renewal of expired access token
2 parents 0c3aeeb + 4aea4fe commit 7bc4517

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

connections/github.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
_gh = None
99

1010
def get_token():
11-
global token
11+
global _token
1212
app_id = config.get_section('github').get('app_id')
1313
installation_id = config.get_section('github').get('installation_id')
1414
private_key_path = config.get_section('github').get('private_key')
@@ -19,9 +19,9 @@ def get_token():
1919

2020
github_integration = GithubIntegration(app_id, private_key)
2121
# Note that installation access tokens last only for 1 hour, you will need to regenerate them after they expire.
22-
token = github_integration.get_access_token(installation_id)
22+
_token = github_integration.get_access_token(installation_id)
2323

24-
return token
24+
return _token
2525

2626

2727
def connect():
@@ -30,6 +30,6 @@ def connect():
3030

3131
def get_instance():
3232
global _gh, _token
33-
if not _gh or (_token and datetime.datetime.utcnow() > token.expires_at):
33+
if not _gh or (_token and datetime.datetime.utcnow() > _token.expires_at):
3434
_gh = connect()
3535
return _gh

0 commit comments

Comments
 (0)