Improve IsExpired with proper auth check

This commit is contained in:
GMatrixGames 2022-11-15 11:18:20 -05:00 committed by GitHub
parent ede6628a2d
commit 9d7e491bf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,9 @@ public class EpicApiEndpoint : AbstractApiProvider
private bool IsExpired()
{
if (string.IsNullOrEmpty(UserSettings.Default.LastAuthResponse.AccessToken)) return true;
return DateTime.Now.Subtract(TimeSpan.FromHours(1)) >= UserSettings.Default.LastAuthResponse.ExpiresAt;
var request = new FRestRequest("https://account-public-service-prod.ol.epicgames.com/account/api/oauth/verify");
request.AddHeader("Authorization", $"bearer {UserSettings.Default.LastAuthResponse.AccessToken}");
var response = _client.Get(request);
return response.StatusCode != HttpStatusCode.OK;
}
}