Azure Mobile Services, Part 2: Listing 3

Live Connect/Azure Mobile Service Login Method

private async Task Login()
    while (_liveConnectSession == null)
        LiveLoginResult liveLoginResult = await _liveAuthClient.LoginAsync(new[] { "wl.basic" });
        if (liveLoginResult.Status == LiveConnectSessionStatus.Connected)
            _liveConnectSession = liveLoginResult.Session;
            LiveConnectClient liveConnectClient = new LiveConnectClient(liveLoginResult.Session);
            LiveOperationResult liveOpResult = await liveConnectClient.GetAsync("me");
            MobileServiceUser mobileServiceLoginResult = await 
            _user = new LiveConnectUser(mobileServiceLoginResult.UserId, 
liveOpResult.Result["first_name"].ToString(), liveOpResult.Result["last_name"].ToString());
            MobileUser.DataContext = _user;
            SignOut.IsEnabled = _liveAuthClient.CanLogout;
            Contact.Visibility = Windows.UI.Xaml.Visibility.Visible;
            _liveConnectSession = null;
            var loginErrorDialog = new MessageDialog("Please log in.", "Login");
            loginErrorDialog.Commands.Add(new UICommand("OK"));
            await loginErrorDialog.ShowAsync();

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at [email protected].

comments powered by Disqus


  • .NET Community Toolkit v8.0 Preview Revamps MVVM Library

    Microsoft announced the first preview of .NET Community Toolkit v8.0.0, which revamps the MVVM library and introduces a new GitHub repo to host the project.

  • Microsoft Details Native Integration of Elastic on Azure

    Microsoft detailed the native integration of Elastic tech with its Azure cloud computing platform, increasing application observability.

  • Java on Visual Studio Code Going Cloud Native

    Cloud-native development figures prominently in a new roadmap published by Microsoft's Java on Visual Studio Code dev team.

  • Speed Lines Graphic

    Quantum-Inspired Annealing Using C# or Python

    Dr. James McCaffrey of Microsoft Research explains a new idea that slightly modifies standard simulated annealing by borrowing ideas from quantum mechanics.

Upcoming Events