LiveFX + Windows Live ID Client SDK = Safer Program

Building an application that uses the LiveFX is easy. So is building an application that uses Windows Live ID. Using the Windows Live ID Client SDK also means that you’re not asking a user to supply your application with the username and password which means that the user can remain safe that they’re not just giving out their username and password for the program to with as he wishes. So if both sorts of programs are easy, is it easy to combine the two? Well, yes.

In Visual Studio, I created a quick Windows Form that looks like the following:


In the references, we need the following:


To start off with, let’s initialise the program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsLive.Id.Client;
using Microsoft.LiveFX.Client;
using Microsoft.LiveFX.ResourceModel;

namespace LiveFXBrowser
    public partial class frmMain : Form
        private const string baseUri = "";
        private LiveOperatingEnvironment loe = new LiveOperatingEnvironment();
        private IdentityManager idmgr;
        private Identity id;

        public frmMain()
                // Create an instance of the ID Manager for the WLID Client
                idmgr = IdentityManager.CreateInstance("ScottIsAFool;[email protected];LiveFX Browser", "LiveFX Browser");
                id = idmgr.CreateIdentity();
                // TODO: Something

Then, let’s look at the code for when we click on the sign in button:

        private void llSignInSignOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
                if (!id.IsAuthenticated)

                    // Load the WLID Sign in window

                    if (id.IsAuthenticated)
                        // Create the Uri for the LiveFX
                        Uri uri = new Uri(baseUri);
                        // Get the authenticated token for the user for LiveFX
                        string token = id.GetTicket("", "MBI_SSL", true);
                        // Connect to the LiveFX
                        loe.Connect(token, AuthenticationTokenType.UserToken, uri, new LiveItemAccessOptions(true));

                        // Set the footer status and sign in text to indicate signed in.
                        tsStatusFooter.Text = "Signed in as: " + loe.Mesh.ProvisionedUser.Name + ".";
                        llSignInSignOut.Text = "Sign out";

                        Profile prof = loe.Profiles.Entries.Single(p => p.Resource.Title == "GeneralProfile");
                        var _messengerPSM = (GeneralProfile)prof.Resource.ProfileInfo;

                        txbxMessengerPSM.Text = _messengerPSM.PersonalStatusMessage;
                    // Close the WLID session
                    tsStatusFooter.Text = "Not signed in";
                    llSignInSignOut.Text = "Sign in.";

As you can see, the code is similar from both previous projects. The comments in the code should be self explanatory.

The finished program and steps, look like the following:




And there you have it.

If you want to check this out, the source (and the built app) are available from my SkyDrive area.