コード例 #1
0
        private async void WAM_Success(WebAccountManager.WebAccountProviderInfo pi, WebAccountManager.WebAccountInfo wad, WebTokenRequestResult result)
        {
            try
            {
                this.ShowBusyStatus(string.Format(Account.TextWebAccountManagerRetrievingProfile, pi.WebAccountType), true);

                await this.Platform.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)
            {
                this.Platform.Logger.LogError(ex, "Failed to perform work during WAM success");
            }
            finally
            {
                this.Dispose();
                this.ClearStatus();
            }
        }
コード例 #2
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(WebAccountManager.WebAccountProviderInfo pi, WebAccountManager.WebAccountInfo info, WebTokenRequestResult result)
        {
            try
            {
                this.ShowBusyStatus(Account.TextAuthenticating, true);

                // Create an account with the API
                _cts = new CancellationTokenSource();
                using (var api = new ClientApi())
                {
                    var response = await api.AuthenticateAsync(info, _cts.Token);

                    // Authenticate the user into the app
                    await this.Platform.AuthManager.SetUserAsync(response);
                }

                this.ClearStatus();
                this.Platform.Navigation.Home(this.ViewParameter);
            }
            catch (Exception ex)
            {
                await this.HandleExceptionAsync(ex, "Failed to perform work during WAM success");
            }
            finally
            {
                this.Dispose();
            }
        }
コード例 #3
0
 private async void WAM_Failed(WebAccountManager.WebAccountProviderInfo pi, WebTokenRequestResult result)
 {
     try
     {
         this.Platform.Logger.LogError(result?.ResponseError.ToException(), "WAM failed to retrieve user account token.");
         await this.ShowMessageBoxAsync(CancellationToken.None, "Could not retrieve your Microsoft Account profile to pre-fill your account registration.");
     }
     catch (Exception ex)
     {
         this.Platform.Logger.LogError(ex, "Failed to perform work during WAM failure");
     }
 }
コード例 #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(WebAccountManager.WebAccountProviderInfo pi, WebTokenRequestResult result)
 {
     try
     {
         // Failure with WAM
         this.Platform.Logger.LogError(result?.ResponseError.ToException(), "WAM failed to retrieve user account token.");
         await this.ShowMessageBoxAsync(CancellationToken.None, string.Format(Account.TextWebAccountManagerRegisterAccountFailure, pi.WebAccountType));
     }
     catch (Exception ex)
     {
         await this.HandleExceptionAsync(ex, "Failed to perform work during WAM failure");
     }
 }