TelemetryPublisherFirestore.cs Increase authorization renewal from 5min to 15min before expiry time.

This commit is contained in:
Denis-Cosmin Nutiu 2020-11-24 23:39:37 +02:00
parent b6f42a7358
commit 535e348ec6

View file

@ -87,6 +87,7 @@ namespace NucuCar.Telemetry.Publishers
if (response?.StatusCode == HttpStatusCode.OK) if (response?.StatusCode == HttpStatusCode.OK)
{ {
Logger?.LogInformation("Firestore authentication OK!");
var jsonContent = await response.GetJson(); var jsonContent = await response.GetJson();
_idToken = jsonContent.GetProperty("idToken").ToString(); _idToken = jsonContent.GetProperty("idToken").ToString();
// Setup next expire. // Setup next expire.
@ -109,8 +110,8 @@ namespace NucuCar.Telemetry.Publishers
return; return;
} }
// Check if the token is about to expire in the next 5 minutes. // Check if the token is about to expire in the next 15 minutes.
if (DateTime.UtcNow.AddMinutes(5) < _authorizationExpiryTime) if (DateTime.UtcNow.AddMinutes(15) < _authorizationExpiryTime)
{ {
return; return;
} }