Beispiel #1
0
        /// <summary>
        /// Flow to perform on successful pick of an account from the WAM popup
        /// </summary>
        /// <param name="pi">Details of the WAM provider choosen</param>
        /// <param name="info">Details of the WAM authenticated account</param>
        /// <param name="result">WebTokenRequestResult instance containing token info.</param>
        private async void WAM_Success(Services.WebAccountManager.WebAccountProviderInfo pi, Services.WebAccountManager.WebAccountInfo info, WebTokenRequestResult result)
        {
            try
            {
                this.ShowBusyStatus(Strings.Account.TextAuthenticating, true);

                // Create an account with the API
                _cts = new CancellationTokenSource();

                var response = await DataSource.Current.AuthenticateAsync(info, _cts.Token);

                // Authenticate the user into the app
                Platform.Current.AuthManager.SetUser(response);

                Platform.Current.Navigation.Home(this.ViewParameter);
            }
            catch (Exception ex)
            {
                Platform.Current.Logger.LogError(ex, "Failed to perform work during WAM success");
            }
            finally
            {
                this.Dispose();
                this.ClearStatus();
            }
        }
        private async void WAM_Success(Services.WebAccountManager.WebAccountProviderInfo pi, Services.WebAccountManager.WebAccountInfo wad, WebTokenRequestResult result)
        {
            try
            {
                this.ShowBusyStatus(string.Format(Strings.Account.TextWebAccountManagerRetrievingProfile, pi.WebAccountType), true);

                await Platform.Current.WebAccountManager.SignoutAsync();

                _cts = new CancellationTokenSource();
                using (var api = new MicrosoftApi())
                {
                    var msa = await api.GetUserProfile(wad.Token, _cts.Token);

                    this.Populate(msa);
                }
            }
            catch (Exception ex)
            {
                Platform.Current.Logger.LogError(ex, "Failed to perform work during WAM success");
            }
            finally
            {
                this.Dispose();
                this.ClearStatus();
            }
        }
 private async void WAM_Failed(Services.WebAccountManager.WebAccountProviderInfo pi, WebTokenRequestResult result)
 {
     try
     {
         Platform.Current.Logger.LogError(result?.ResponseError.ToException(), "WAM failed to retrieve user account token.");
         await this.ShowMessageBoxAsync("Could not retrieve your Microsoft Account profile to pre-fill your account registration.");
     }
     catch (Exception ex)
     {
         Platform.Current.Logger.LogError(ex, "Failed to perform work during WAM failure");
     }
 }
Beispiel #4
0
 /// <summary>
 /// Flow to perform on any failures from the WAM popup
 /// </summary>
 /// <param name="pi"></param>
 /// <param name="result"></param>
 private async void WAM_Failed(Services.WebAccountManager.WebAccountProviderInfo pi, WebTokenRequestResult result)
 {
     try
     {
         // Failure with WAM
         Platform.Current.Logger.LogError(result?.ResponseError.ToException(), "WAM failed to retrieve user account token.");
         await this.ShowMessageBoxAsync(string.Format(Strings.Account.TextWebAccountManagerRegisterAccountFailure, pi.WebAccountType));
     }
     catch (Exception ex)
     {
         Platform.Current.Logger.LogError(ex, "Failed to perform work during WAM failure");
     }
 }