App Class

Current information about Live Connect is now available in the Windows Live Developer Center. The information in the following sections is provided for legacy purposes only.

Represents a Windows Live application. Use the App class to set and get all properties of an instance of a Windows Live application and to manage initialization and sign-in.

Feature:  Microsoft.Live
Namespace:  Microsoft.Live

The JavaScript Library for Windows Live Messenger Connect is built by using the Microsoft Ajax Library. Microsoft Ajax exposes a type system that enables you to add object-oriented capabilities to your JavaScript code. To learn more about creating, instantiating, and deriving from classes, see Creating Custom Client Script by Using the Microsoft Ajax Library.

Microsoft.Live.App = function();


You can work with an instance of an application by using an instance of the App class to make explicit API calls. Because App is a static class, it cannot be created directly by using the constructor. Instead, call the Microsoft.Live.App.initialize method.

You can also create an instance of App by using XML markup, by embedding an <app> tag in an HTML or ASP.NET page. For more information, see Application Control.

The following code example shows four functions. The first function, bodyonload, is called when the HTML page loads. This function shows how to include the onload attribute in the body tag. It also demonstrates the use of closure to call Microsoft.Live.App.initialize, by using JavaScript Object Notation (JSON) markup to pass the channel URL and the name of the callback function (appLoaded).

<body onload="bodyOnload();">

function bodyOnload() {
    Microsoft.Live.Core.Loader.onload([""], function () {
            channelurl: "http://<Your-Domain>/channel.html",
            callbackurl: "http://<Your-Domain>/OAuthWrapCallback.axd",
            clientid: "<Your-Client-ID>",
            scope: "WL_Contacts.View",
            onload: "appOnload"

As an alternative, you can insert the <app> tag directly into your HTML or ASP page as shown in the following example.


In the next example, the Microsoft.Live.ApplicationLoadCompletedEventArgs.dataContext, and Microsoft.Live.App.auth properties are returned.

function appOnload(evtArgs) {
    appContext = evtArgs.get_dataContext();
    auth = Microsoft.Live.App.get_auth();
    Sys.Debug.trace("The application has successfully loaded.");

The signin function demonstrates how to call the Microsoft.Live.App.signIn method, which presents users with the interface for signing in with their Windows Live ID.

The final function, named signInComplete, shows how to obtain the data context from the SignInCompletedEventArgs instance. This is where most of the action takes place in the application. This function also contains some rudimentary error-handling code that is triggered if the sign-in fails for any reason.

// Sign in - connect to Windows Live (connect to user data).
// When done call the callback method (signInComplete).
function signin() {

function signInComplete(signInCompletedEventArgs) {
    if (signInCompletedEventArgs.get_resultCode() != Microsoft.Live.AsyncResultCode.success) {
        alert("sign-in failed: " + signInCompletedEventArgs.get_resultCode());
    else {
    // Get LiveDataContext and perform some operations, such as loading contacts.            
    var dataContext = signInCompletedEventArgs.get_dataContext();

You can also sign out programmatically by calling Microsoft.Live.App.signOut, as shown in the following example.

function signout() {

function signOutComplete() {
    alert("You have been signed out.");


Windows Live Messenger Connect

Supported in: 4.1

Internet Explorer 8.0, Internet Explorer 7.0, Internet Explorer 6.0, Firefox 3.6, Firefox 3.5, Firefox 3.0, Firefox 2.0, Firefox 1.5, Chrome 4.0, Chrome 3.0, Chrome 2.0, Chrome 1.0, Safari 4.0, Safari 3.0