It’s a common usage, these days, to develop applications that allow users to access their personal data and Windows Live (documents, pictures, etc.) is a good example of the kind of data someone might want to access from everywhere.
Until now, developers needed to develop custom systems to access the data on the cloud, when it was possible. But thanks to Microsoft and it’s Live SDK, it’s possible to access any Windows Live data from Windows Phone or Windows 8 application (HTML or XAML).
First thing to do is to create Client ID for the application you want to develop. This ID will be used to authenticate your application and ensure that user can trust it. To create your Client ID, go to https://manage.dev.live.com and create an application (simply provide its name and its language):
Once the application is created, don’t forget to edit its settings to indicate that it’s a mobile app and not a desktop app:
Now, it’s start to develop the Windows Phone application. Add a reference to the 2 DLLs provided in the SDK (C:\Program Files (x86)\Microsoft SDKs\Live\v5.0\Windows Phone\References):
Now, in your XAML file, add the following code, which will provide you a button to allow users to connect to their Live account:
Scopes="wl.basic wl.photos wl.skydrive wl.offline_access wl.signin wl.skydrive_update"
There are a lot of properties that you can changed (you can see the whole documentation here: http://msdn.microsoft.com/en-us/library/hh243650.aspx) but the most important are:
- ClientId: This is the number that you’ve generated in the first part
- Scopes: The list of “features” that your application will be allowed to manipulate. In our example, the application will get access to basic data, photos, Skydrive, ability to reconnect, etc.
In the code-behind, add the following code, used to be notified when the user is connected and then, get access to its name:
private void OnSessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
if(e.Error == null)
if (e.Status == LiveConnectSessionStatus.Connected)
this._currentSession = e.Session;
var client = new LiveConnectClient(this._currentSession);
client.GetCompleted += (o, args) =>
if (args.Error == null)
Now, when user execute your application, it get a button he can use to log on Windows Live:
Once logged in, a page display which data the application will be able to use:
Then, the user is authenticated and the code to retrieved its name is executed:
Of course, this sample is pretty simple and it’s possible to perform more complex task such as upload/downloading pictures, etc.
Feel free to take a look by yourself!