Пример #1
0
        /// <summary>
        /// Refreshes internal token object
        /// </summary>
        public async Task <OAuthToken> RefreshOAuthTokenAsync()
        {
            var refreshedToken = await RefreshOAuthTokenAsync(this.OAuthToken).ConfigureAwait(false);

            this.OAuthToken = refreshedToken;

            // replace access_token field on server
            RefreshTokenEvent?.Invoke(this, new AsanaRefreshTokenEventArgs(refreshedToken));

            return(this.OAuthToken);
        }
Пример #2
0
 public async Task GetAnime(ConcurrentBag <SpecialUserAnimeRate> outContainer, AnimeStatus status = AnimeStatus.None)
 {
     try
     {
         await UserAnimeRequest.GetSpecialAnime(this.CurrentUser, this.AuthToken, outContainer, status).ConfigureAwait(false);
     }
     catch (TokenExpiredException e)
     {
         RefreshTokenEvent?.Invoke(this.AuthToken);
         ErrorTextEvent?.Invoke(e.Message);
         return;
     }
     catch (Exception e)
     {
         ErrorTextEvent?.Invoke(e.Message);
         return;
     }
 }
Пример #3
0
 public async Task GetAnime(List <UserAnimeRate> testlist, int limitItemsByReq = 50)
 {
     try
     {
         await UserAnimeRequest.GetUserAnime(this.CurrentUser, this.AuthToken, limitItemsByReq, testlist).ConfigureAwait(false);
     }
     catch (TokenExpiredException e)
     {
         RefreshTokenEvent?.Invoke(this.AuthToken);
         ErrorTextEvent?.Invoke("Token expired,refreshing, try again");
         return;
     }
     catch (Exception e)
     {
         ErrorTextEvent?.Invoke(e.Message);
         return;
     }
 }
Пример #4
0
        private async Task GetCurrentUser()
        {
            try
            {
                var user = await WhoAmIRequest.Whoami(this.AuthToken).ConfigureAwait(false);

                this.CurrentUser = user;
            }
            catch (TokenExpiredException e)
            {
                RefreshTokenEvent?.Invoke(this.AuthToken);
                ErrorTextEvent?.Invoke(e.Message);
            }
            catch (Exception e)
            {
                ErrorTextEvent?.Invoke(e.Message);
            }
        }
Пример #5
0
        private async Task GetToken(string authCode)
        {
            try
            {
                var tok = await AuthRequest.Authorization(authCode).ConfigureAwait(false);

                this.AuthToken = tok;
            }
            catch (TokenExpiredException e)
            {
                RefreshTokenEvent?.Invoke(this.AuthToken);
                //ErrorTextEvent?.Invoke(e.Message);
            }
            catch (Exception e)
            {
                //ErrorTextEvent?.Invoke(e.Message);
                throw;
            }
        }