本文整理汇总了C#中Microsoft.Live.LiveAuthClient.Logout方法的典型用法代码示例。如果您正苦于以下问题:C# LiveAuthClient.Logout方法的具体用法?C# LiveAuthClient.Logout怎么用?C# LiveAuthClient.Logout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Live.LiveAuthClient
的用法示例。
在下文中一共展示了LiveAuthClient.Logout方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SignOutButton_OnClick
private async void SignOutButton_OnClick(object sender, RoutedEventArgs e)
{
try
{
// Initialize access to the Live Connect SDK.
LiveAuthClient LCAuth = new LiveAuthClient();
LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
// Sign the user out, if he or she is connected;
// if not connected, skip this and just update the UI
if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
{
LCAuth.Logout();
}
// At this point, the user should be disconnected and signed out, so
// update the UI.
var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
this.UserNameTextBlock.Text = loader.GetString("MicrosoftAccount/Text");
// Show sign-in button.
SignInButton.Visibility = Visibility.Visible;
SignOutButton.Visibility = Visibility.Collapsed;
}
catch (LiveConnectException x)
{
// Handle exception.
}
}
示例2: SignOutClick
private async void SignOutClick(object sender, RoutedEventArgs e)
{
try
{
// Initialize access to the Live Connect SDK.
LiveAuthClient LCAuth = new LiveAuthClient();
LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
// Sign the user out, if he or she is connected;
// if not connected, skip this and just update the UI
if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
{
LCAuth.Logout();
}
// At this point, the user should be disconnected and signed out, so
// update the UI.
this.userName.Text = "You're not signed in.";
Connection.User = null;
// Show sign-in button.
signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
new MessageDialog("The app is exiting since you are no longer logged in.").ShowAsync();
App.Current.Exit();
}
catch (LiveConnectException x)
{
// Handle exception.
}
}
示例3: SignOutClick
private async void SignOutClick(object sender, RoutedEventArgs e)
{
try
{
// Initialize access to the Live Connect SDK.
LiveAuthClient LCAuth = new LiveAuthClient();
LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
// Sign the user out, if he or she is connected;
// if not connected, skip this and just update the UI
if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
{
LCAuth.Logout();
}
// At this point, the user should be disconnected and signed out, so
// update the UI.
this.userName.Text = "You're not signed in.";
// Show sign-in button.
signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
catch (LiveConnectException x)
{
// Handle exception.
this.userName.Text = x.Message.ToString();
throw new NotImplementedException();
}
}
示例4: Authenticate
/// <summary>
/// Login mit einem entsprechenden Dialog.
/// </summary>
/// <returns>Ein MobileServiceUser, der awaited werden kann oder null bei Misserfolg.</returns>
internal async static Task<MobileServiceUser> Authenticate(MobileServiceClient mobileService)
{
LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
var source = new TaskCompletionSource<MobileServiceUser>();
liveAuthClient.Logout();
var scopes = new string[] { "wl.basic", "wl.offline_access", "wl.signin" };
App.Current.RootVisual.Visibility = System.Windows.Visibility.Collapsed;
try
{
session = (await liveAuthClient.LoginAsync(scopes)).Session;
}
finally
{
App.Current.RootVisual.Visibility = System.Windows.Visibility.Visible;
}
return await mobileService.LoginWithMicrosoftAccountAsync(session.AuthenticationToken);
}
示例5: Authenticate
private async System.Threading.Tasks.Task Authenticate()
{
LiveAuthClient liveIdClient = new LiveAuthClient("https://sendit.azure-mobile.net/");
while (session == null)
{
// Force a logout to make it easier to test with multiple Microsoft Accounts
if (liveIdClient.CanLogout)
liveIdClient.Logout();
LiveLoginResult result = await liveIdClient.LoginAsync(new[] { "wl.basic" });
if (result.Status == LiveConnectSessionStatus.Connected)
{
session = result.Session;
LiveConnectClient client = new LiveConnectClient(result.Session);
LiveOperationResult meResult = await client.GetAsync("me");
MobileServiceUser loginResult = await App.MobileService.LoginAsync(result.Session.AuthenticationToken);
string title = string.Format("Welcome {0}!", meResult.Result["first_name"]);
var message = string.Format("You are now logged in - {0}", loginResult.UserId);
var dialog = new MessageDialog(message, title);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
else
{
session = null;
var dialog = new MessageDialog("You must log in.", "Login Required");
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
}
示例6: Authenticate
public async Task Authenticate()
{
// For Microsoft ID to work in Windows 8, you need to associate the Windows 8 app
// with a Windows 8 Store app (ie: create an app in the Store/reserve a name)
// you do not need to publish the app to test
var liveIdClient = new LiveAuthClient("https://headstails.azure-mobile.net/");
while (App.liveConnectSession == null)
{
// Force a logout to make it easier to test with multiple Microsoft Accounts
if (liveIdClient.CanLogout)
liveIdClient.Logout();
CurrentLoginStatus = "Connecting to Microsoft Services";
// as per: http://stackoverflow.com/questions/17938828/obtaining-the-users-email-address-from-the-live-sdk
var result = await liveIdClient.LoginAsync(new[] { "wl.emails" });
if (result.Status == LiveConnectSessionStatus.Connected)
{
CurrentLoginStatus = "Connected to Microsoft Services";
App.liveConnectSession = result.Session;
var client = new LiveConnectClient(result.Session);
microsoftAccountLoggedInUser = await client.GetAsync("me");
CurrentLoginStatus = "Getting Microsoft Account Details";
mobileServiceLoggedInUser = await App.MobileService.LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);
var remoteLeaderBoard = App.MobileService.GetTable<Leaderboard>();
remoteLeaderBoard = App.MobileService.GetTable<Leaderboard>();
CurrentLoginStatus = string.Format("Welcome {0}!", microsoftAccountLoggedInUser.Result["name"]);
userName = microsoftAccountLoggedInUser.Result["name"].ToString();
await Task.Delay(2000); // non-blocking Thread.Sleep for 2000ms (2 seconds)
CurrentlyLoggedIn = true; // this will then flip the bit that shows the different UI for logged in
}
else
{
CurrentLoginStatus = "Y U NO LOGIN?";
CurrentlyLoggedIn = false;
}
}
}
示例7: DisconnectAsync
public async Task DisconnectAsync()
{
var cl = new LiveAuthClient(CLIENT_ID);
await cl.Initialize();
if (cl.Session != null)
{
cl.Logout();
}
}
示例8: SignOut
// Remove user and record
public void SignOut()
{
LiveAuthClient liveAuthClient = new LiveAuthClient(LIVE_CLIENT_ID);
liveAuthClient.Logout();
App.ApplicationSettings.Remove(ONE_DRIVE_SIGN_IN_KEY);
StorageExplorer.RemoveKey(this.GetStorageName());
this.LiveClient = null;
this.CurrentAccount = null;
}
示例9: Logout
/// <summary>
/// Loggt den aktuellen Nutzer aus.
/// </summary>
internal static void Logout()
{
LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
liveAuthClient.Logout();
}
示例10: Authenticate
public async Task Authenticate()
{
var liveIdClient = new LiveAuthClient();
while (_session == null)
{
//
// ToDo: Determine if this code is necessary:
// Force a logout to make it easier to test with multiple Microsoft Accounts
//
if (liveIdClient.CanLogout)
liveIdClient.Logout();
LiveLoginResult result = await liveIdClient.LoginAsync(new[] {"wl.basic", "wl.emails"});
if (result.Status == LiveConnectSessionStatus.Connected)
{
_session = result.Session;
var client = new LiveConnectClient(result.Session);
LiveOperationResult meResult = await client.GetAsync("me");
dynamic dynamicResult = meResult.Result;
string userName = "";
string email = "";
try
{
userName = string.Format("{0} {1}", dynamicResult.first_name, dynamicResult.last_name);
email = dynamicResult.emails.preferred;
Settings.EmailAddress = email;
//Settings.EmailAddress = "[email protected]";
var roomManager = RoomManager.GetInstance();
roomManager.AddMemberToRoom(Settings.userInstance);
roomManager.ChangeRoomHost(Settings.userInstance);
}
catch
{
// Todo: determine what to do here if this fails...
}
var mainPageViewModel = MainPageViewModel.GetInstance();
mainPageViewModel.UserName = string.Format("Welcome {0}!", meResult.Result["first_name"]);
}
else
{
_session = null;
var dialog = new MessageDialog("You must log in.", "Login Required");
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
}
示例11: Disconnect
public void Disconnect() {
var cl = new LiveAuthClient("00000000480F4F1E");
cl.Logout();
}
示例12: Cleanup
public override void Cleanup()
{
var aC = new LiveAuthClient(ClientId, RedirectUri);
aC.Logout();
base.Cleanup();
}