mirror of
https://github.com/4sval/FModel.git
synced 2026-06-25 01:10:29 -05:00
exception fix
This commit is contained in:
parent
794403afbf
commit
2fea609a63
|
|
@ -1,11 +1,15 @@
|
|||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using EpicManifestParser.Objects;
|
||||
|
||||
using FModel.Framework;
|
||||
using FModel.Settings;
|
||||
using FModel.ViewModels.ApiEndpoints.Models;
|
||||
|
||||
using RestSharp;
|
||||
|
||||
using Serilog;
|
||||
|
||||
namespace FModel.ViewModels.ApiEndpoints;
|
||||
|
|
@ -22,9 +26,9 @@ public class EpicApiEndpoint : AbstractApiProvider
|
|||
|
||||
public async Task<ManifestInfo> GetManifestAsync(CancellationToken token)
|
||||
{
|
||||
if (IsExpired())
|
||||
if (await IsExpired().ConfigureAwait(false))
|
||||
{
|
||||
var auth = await GetAuthAsync(token);
|
||||
var auth = await GetAuthAsync(token).ConfigureAwait(false);
|
||||
if (auth != null)
|
||||
{
|
||||
UserSettings.Default.LastAuthResponse = auth;
|
||||
|
|
@ -53,12 +57,12 @@ public class EpicApiEndpoint : AbstractApiProvider
|
|||
return response.Data;
|
||||
}
|
||||
|
||||
private bool IsExpired()
|
||||
private async Task<bool> IsExpired()
|
||||
{
|
||||
if (string.IsNullOrEmpty(UserSettings.Default.LastAuthResponse.AccessToken)) return true;
|
||||
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);
|
||||
var response = await _client.ExecuteAsync(request).ConfigureAwait(false);
|
||||
return response.StatusCode != HttpStatusCode.OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user