public override bool Logout() { if (string.IsNullOrEmpty(ClientId)) { EtcUtility.Instance.MsgBox("ClientId Required"); return(false); } var returnValue = false; if (AuthClient == null) { AuthClient = authClient = new LiveAuthClient(ClientId); } else { authClient = (LiveAuthClient)AuthClient; } authClient.Logout(); IsSignIn = false; User = null; returnValue = true; return(returnValue); }
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) { // Handle exception. } }
public async Task <ConnectionResult> DisconnectAsync() { var authClient = new LiveAuthClient(); try { var loginResult = await authClient.InitializeAsync(); // Sign the user out, if he or she is connected; // if not connected, skip this and just update the UI if (loginResult.Status == LiveConnectSessionStatus.Connected && authClient.CanLogout) { authClient.Logout(); UpdateSession(null); } var result = new ConnectionResult { SessionStatus = LiveConnectSessionStatus.NotConnected, CanLogout = authClient.CanLogout, }; return(result); } catch (LiveConnectException ex) { // TODO - Handle exception. throw new InvalidOperationException("Failed to disconnect.", ex); } }
private void SignOut(object sender, RoutedEventArgs e) { LiveAuthClient auth = new LiveAuthClient(); try { auth.Logout(); infoTextBlock.Text = "Logged Out"; } catch (Exception ec) { infoTextBlock.Text = ec.ToString(); } }
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 = "*****@*****.**"; 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(); } } }
public static void Logout() { if (_auth != null) { try { _auth.Logout(); } catch (Exception) { } } _client = null; _auth = null; }
// 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; }
public static void Logout() { try { _authClient.Logout(); } catch (LiveConnectException ex) { throw new LiveConnectException(ex.ErrorCode, ex.Message, ex.InnerException); } }
private async System.Threading.Tasks.Task Authenticate() { 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"); //assigning the token generated by LiveConnectClient to the MobileServiceUser MobileServiceUser loginResult = await App.MobileService.LoginAsync(result.Session.AuthenticationToken); var results = await userTable.ToListAsync(); if (results.Count == 0) { var user = new User { LastAccessed = DateTime.Now, UserName = meResult.Result["first_name"].ToString() }; } else { CurrentUser = results.First(); } WelcomeTitle = string.Format("Welcome {0}!", meResult.Result["first_name"]); //Get the photos uploaded by logged in user. var getPictures = await GetMyPhotos(); foreach (var p in getPictures) { myPictures.Add(p); } RaisePropertyChanged("MyPictures"); } else { session = null; var dialog = new MessageDialog("You must log in.", "Login Required"); dialog.Commands.Add(new UICommand("OK")); await dialog.ShowAsync(); } } }
public void Unlink() { _authClient.Logout(); IsSyncing = false; IsLinked = false; _authClient = null; if (_liveClient != null) { _liveClient = null; } }
public void LogoutOneDrive() { try { oneDriveAuthClient.Logout(); oneDriveFolderId = ""; oneDriveFolderIDEnabled = false; OneDriveConnected = false; } catch (LiveAuthException ex) { MessageBox.Show("Error during loing process:" + ex.Message); } catch (LiveConnectException ex) { App.AppViewModel.SendExceptionReport(ex); } }
private async System.Threading.Tasks.Task Authenticate() { LiveAuthClient liveIdClient = new LiveAuthClient("https://idb.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"]); App.LoginName = string.Format("{0}", meResult.Result["name"]); App.Gender = string.Format("{0}", meResult.Result["gender"]); App.UserID = string.Format("{0}", loginResult.UserId); //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(); } } }
/// <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)); }
/// <summary> /// Returns a list of SimpleCommands based on the apps state. This is used /// to populate the Settings panel. /// </summary> public List <SimpleCommand> GetSettingsCommands() { List <SimpleCommand> commands = new List <SimpleCommand>(); // if no user, no need to return any commands if (_mobileServiceClient.CurrentUser == null || _liveAuthClient.CanLogout == false) { return(commands); } // Create the sign out command SimpleCommand signOut = new SimpleCommand(); signOut.Text = string.Format("Sign Out {0}", User.Name); signOut.Action = () => { _mobileServiceClient.Logout(); _liveAuthClient.Logout(); SetViewState(ViewState.LoggedOut); }; commands.Add(signOut); return(commands); }
public override void Disconnect() { _session = null; User = null; _liveIdClient.Logout(); }
/// <summary> /// Loggt den aktuellen Nutzer aus. /// </summary> internal static void Logout() { LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId); liveAuthClient.Logout(); }
public void Logout() { var liveAuth = new LiveAuthClient(Constants.MICROSOFT_LIVE_CLIENTID); liveAuth.Logout(); }