Exemplo n.º 1
0
        public async Task <bool> RefreshAccessToken()
        {
            var url = _config.ApiUrl + "/token?grant_type=refresh_token"
                      + $"&refresh_token={_tokenData.RefreshToken}"
                      + $"&client_id={_config.ClientId}"
                      + $"&client_secret={_config.ClientSecret}";
            var httpClient = new HttpClient();
            var response   = await httpClient.PostAsync(url, null);

            if (response.IsSuccessStatusCode)
            {
                _tokenData =
                    JsonConvert.DeserializeObject <PatreonTokenData>(
                        await response.Content.ReadAsStringAsync());
                await SetTokenDataToS3(_tokenData);

                return(true);
            }

            _logger.LogError(
                $"Can't referesh patreon token. Status code: {response.StatusCode}. Response: {await response.Content.ReadAsStringAsync()}");
            throw new Exception("Patreon refresh token error");
        }
 private Task SetTokenDataToS3Async(PatreonTokenData data)
 {
     return(_s3Client.UploadJsonAsync(data, _config.S3ObjectKey, _s3Config.Bucket));
 }
Exemplo n.º 3
0
 private async Task <bool> SetTokenDataToS3(PatreonTokenData data)
 {
     return(await _s3Provider.UploadJson(data, _config.S3BucketName, _config.S3ObjectKey));
 }
Exemplo n.º 4
0
        public async Task <bool> LoadOAuthData()
        {
            _tokenData = await GetTokenDataFromS3();

            return(true);
        }