Skip to content

Commit e931d02

Browse files
committed
ensure addends are ints
1 parent 0b1e902 commit e931d02

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

msal/token_cache.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import json
1+
import json
22
import threading
33
import time
44
import logging
@@ -128,8 +128,9 @@ def add(self, event, now=None):
128128
with self._lock:
129129

130130
if access_token:
131-
now = time.time() if now is None else now
132-
expires_in = response.get("expires_in", 3599)
131+
now = int(time.time()) if now is None else int(now)
132+
expires_in = int(response.get("expires_in", 3599))
133+
ext_expires_in = int(response.get("ext_expires_in", expires_in))
133134
at = {
134135
"credential_type": self.CredentialType.ACCESS_TOKEN,
135136
"secret": access_token,
@@ -138,10 +139,9 @@ def add(self, event, now=None):
138139
"client_id": event.get("client_id"),
139140
"target": target,
140141
"realm": realm,
141-
"cached_at": str(int(now)), # Schema defines it as a string
142-
"expires_on": str(int(now + expires_in)), # Same here
143-
"extended_expires_on": str(int( # Same here
144-
now + response.get("ext_expires_in", expires_in))),
142+
"cached_at": str(now), # Schema defines it as a string
143+
"expires_on": str(now + expires_in), # Same here
144+
"extended_expires_on": str(now + ext_expires_in) # Same here
145145
}
146146
self.modify(self.CredentialType.ACCESS_TOKEN, at, at)
147147

0 commit comments

Comments
 (0)