Пример #1
0
        private async Task TryGetToken(TokenListener tokenListener)
        {
            _loginTask = _loginTask ?? _internalAuthService.LoginWithXToken(_userInfo.Xtoken);

            Union3 <UserInfo, LoginErrorDto, Exception> loginResult = await _loginTask;

            loginResult.Match(userInfo =>
            {
                _userInfo.Token = userInfo.Token;
                _userInfo.Uid   = userInfo.Uid;
                tokenListener.OnTokenReceived(_userInfo.Token);
            },
                              error =>
            {
                tokenListener.OnTokenRefreshFailed(error.Error);
                AppAnalytics.Instance.TrackError(error.ErrorDescription);
            },
                              ex =>
            {
                tokenListener.OnTokenRefreshFailed(ex.Message);
                AppAnalytics.Instance.TrackError(ex);
            });

            _loginTask = null;
        }
Пример #2
0
 public async void RequestToken(TokenListener tokenListener)
 {
     if (!string.IsNullOrWhiteSpace(_userInfo.Token))
     {
         tokenListener.OnTokenReceived(_userInfo.Token);
     }
     else
     {
         await TryGetToken(tokenListener);
     }
 }