File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ def _parse_expiry(response_data):
120120 expires_in = response_data .get ("expires_in" , None )
121121
122122 if expires_in is not None :
123+ # Some services do not respect the OAUTH2.0 RFC and send expires_in as a
124+ # JSON String.
125+ if isinstance (expires_in , str ):
126+ expires_in = int (expires_in )
127+
123128 return _helpers .utcnow () + datetime .timedelta (seconds = expires_in )
124129 else :
125130 return None
Original file line number Diff line number Diff line change @@ -99,9 +99,10 @@ def test__can_retry_no_retry_message(response_data):
9999 assert not _client ._can_retry (http_client .OK , response_data )
100100
101101
102+ @pytest .mark .parametrize ("mock_expires_in" , [500 , "500" ])
102103@mock .patch ("google.auth._helpers.utcnow" , return_value = datetime .datetime .min )
103- def test__parse_expiry (unused_utcnow ):
104- result = _client ._parse_expiry ({"expires_in" : 500 })
104+ def test__parse_expiry (unused_utcnow , mock_expires_in ):
105+ result = _client ._parse_expiry ({"expires_in" : mock_expires_in })
105106 assert result == datetime .datetime .min + datetime .timedelta (seconds = 500 )
106107
107108
You can’t perform that action at this time.
0 commit comments