Skip to content

Commit

Permalink
fix: refresh access token if expired
Browse files Browse the repository at this point in the history
  • Loading branch information
Niccari committed Jun 20, 2024
1 parent 7369b6b commit 125a81d
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 125a81d

Please sign in to comment.