本文整理匯總了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.");
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}