當前位置: 首頁>>代碼示例>>C#>>正文


C# MobileServiceClient.RefreshUserAsync方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.MobileServices.MobileServiceClient.RefreshUserAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# MobileServiceClient.RefreshUserAsync方法的具體用法?C# MobileServiceClient.RefreshUserAsync怎麽用?C# MobileServiceClient.RefreshUserAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.MobileServices.MobileServiceClient的用法示例。


在下文中一共展示了MobileServiceClient.RefreshUserAsync方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnClickTwitterLoginAndRefresh

        private async void OnClickTwitterLoginAndRefresh(object sender, EventArgs eventArgs)
        {
            var client = new MobileServiceClient(this.uriText.Text);
            var user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Twitter);

            try
            {
                await client.RefreshUserAsync();
            }
            catch (MobileServiceInvalidOperationException ex)
            {
                Assert.IsNotNull(ex.InnerException);
                Assert.AreEqual(HttpStatusCode.BadRequest, ex.Response.StatusCode);
                Assert.AreEqual(RefreshUser400ErrorMessage, ex.Message);
                string message = "Twitter LoginAsync succeeded. RefreshAsync is not supported by Twitter. UserId: " + user.UserId;
                this.loginTestResult.Text = message;
                System.Diagnostics.Debug.WriteLine(message);
                return;
            }

            Assert.Fail("RefreshAsync() should throw 400 error on Twitter account.");
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:22,代碼來源:LoginActivity.cs

示例2: OnClickGoogleLoginAndRefresh

        private async void OnClickGoogleLoginAndRefresh(object sender, EventArgs eventArgs)
        {
            this.loginTestResult.Text = string.Empty;

            var client = new MobileServiceClient(this.uriText.Text);
            var user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Google,
                new Dictionary<string, string>()
                {
                    { "access_type", "offline" }
                });
            string authToken = user.MobileServiceAuthenticationToken;
            this.loginTestResult.Text = "Google LoginAsync succeeded. UserId: " + user.UserId;

            MobileServiceUser refreshedUser = await client.RefreshUserAsync();

            Assert.AreEqual(user.UserId, refreshedUser.UserId);
            Assert.AreNotEqual(authToken, refreshedUser.MobileServiceAuthenticationToken);

            string message = "Google LoginAsync succeeded. Google RefreshAsync succeeded. UserId: " + user.UserId;
            this.loginTestResult.Text = message;
            System.Diagnostics.Debug.WriteLine(message);
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:22,代碼來源:LoginActivity.cs

示例3: OnClickMicrosoftAccountLoginAndRefresh

        private async void OnClickMicrosoftAccountLoginAndRefresh(object sender, EventArgs eventArgs)
        {
            this.loginTestResult.Text = string.Empty;

            var client = new MobileServiceClient(this.uriText.Text);
            var user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.MicrosoftAccount);
            string authToken = user.MobileServiceAuthenticationToken;
            this.loginTestResult.Text = "MicrosoftAccount LoginAsync succeeded. UserId: " + user.UserId;

            MobileServiceUser refreshedUser = await client.RefreshUserAsync();

            Assert.AreEqual(user.UserId, refreshedUser.UserId);
            Assert.AreNotEqual(authToken, refreshedUser.MobileServiceAuthenticationToken);

            string message = "MicrosoftAccount LoginAsync succeeded. MicrosoftAccount RefreshAsync succeeded. UserId: " + user.UserId;
            this.loginTestResult.Text = message;
            System.Diagnostics.Debug.WriteLine(message);
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:18,代碼來源:LoginActivity.cs

示例4: LoginAndRefreshWithMicrosoftAccount

        private async void LoginAndRefreshWithMicrosoftAccount()
        {
            var client = new MobileServiceClient(this.uriEntry.Value);
            MobileServiceUser user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.MicrosoftAccount);
            string authToken = user.MobileServiceAuthenticationToken;

            MobileServiceUser refreshedUser = await client.RefreshUserAsync();

            Assert.AreEqual(user.UserId, refreshedUser.UserId);
            Assert.AreNotEqual(authToken, refreshedUser.MobileServiceAuthenticationToken);

            var alert = new UIAlertView("Welcome", "Microsoft Account Login and Refresh User succeeded. Your userId is: " + user.UserId, null, "OK");
            alert.Show();
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:14,代碼來源:LoginViewController.cs

示例5: LoginAndRefreshWithGoogle

        private async void LoginAndRefreshWithGoogle()
        {
            var client = new MobileServiceClient(this.uriEntry.Value);
            MobileServiceUser user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Google,
                new Dictionary<string, string>()
                {
                    { "access_type", "offline" }
                });
            string authToken = user.MobileServiceAuthenticationToken;

            MobileServiceUser refreshedUser = await client.RefreshUserAsync();

            Assert.AreEqual(user.UserId, refreshedUser.UserId);
            Assert.AreNotEqual(authToken, refreshedUser.MobileServiceAuthenticationToken);

            var alert = new UIAlertView("Welcome", "Google Login and Refresh User succeeded. Your userId is: " + user.UserId, null, "OK");
            alert.Show();
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:18,代碼來源:LoginViewController.cs

示例6: LoginAndRefreshWithAAD

        private async void LoginAndRefreshWithAAD()
        {
            var client = new MobileServiceClient(this.uriEntry.Value);
            MobileServiceUser user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory,
                new Dictionary<string, string>()
                {
                    { "response_type", "code id_token" }
                });
            string authToken = user.MobileServiceAuthenticationToken;

            MobileServiceUser refreshedUser = await client.RefreshUserAsync();

            Assert.AreEqual(user.UserId, refreshedUser.UserId);
            Assert.AreNotEqual(authToken, refreshedUser.MobileServiceAuthenticationToken);

            var alert = new UIAlertView("Welcome", "AAD Login and Refresh User succeeded. Your userId is: " + user.UserId, null, "OK");
            alert.Show();
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:18,代碼來源:LoginViewController.cs


注:本文中的Microsoft.WindowsAzure.MobileServices.MobileServiceClient.RefreshUserAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。