@@ -54,7 +54,7 @@ def __init__(self):
5454 home_account_id or "" ,
5555 environment or "" ,
5656 self .CredentialType .ACCESS_TOKEN ,
57- client_id ,
57+ client_id or "" ,
5858 realm or "" ,
5959 target or "" ,
6060 ]).lower (),
@@ -128,8 +128,11 @@ 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 now )
132+ expires_in = int ( # AADv1-like endpoint returns a string
133+ response .get ("expires_in" , 3599 ))
134+ ext_expires_in = int ( # AADv1-like endpoint returns a string
135+ response .get ("ext_expires_in" , expires_in ))
133136 at = {
134137 "credential_type" : self .CredentialType .ACCESS_TOKEN ,
135138 "secret" : access_token ,
@@ -138,10 +141,9 @@ def add(self, event, now=None):
138141 "client_id" : event .get ("client_id" ),
139142 "target" : target ,
140143 "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 ))),
144+ "cached_at" : str (now ), # Schema defines it as a string
145+ "expires_on" : str (now + expires_in ), # Same here
146+ "extended_expires_on" : str (now + ext_expires_in ) # Same here
145147 }
146148 self .modify (self .CredentialType .ACCESS_TOKEN , at , at )
147149
0 commit comments