Skip to content

Commit

Permalink
Merge pull request #335 from Niccari/bugfix/refresh_access_token
Browse files Browse the repository at this point in the history
fix: refresh access token
  • Loading branch information
olucurious authored Jun 20, 2024
2 parents 6e7e8d1 + 125a81d commit 7aaf33b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyfcm/baseapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ def requests_session(self):
self.thread_local.requests_session = requests.Session()
self.thread_local.requests_session.mount("http://", adapter)
self.thread_local.requests_session.mount("https://", adapter)
self.thread_local.token_expiry = 0

current_timestamp = time.time()
if self.thread_local.token_expiry < current_timestamp:
self.thread_local.requests_session.headers.update(self.request_headers())
self.thread_local.token_expiry = current_timestamp + 1800
return self.thread_local.requests_session

def send_request(self, payload=None, timeout=None):
Expand Down

0 comments on commit 7aaf33b

Please sign in to comment.