Windows Phone apps

The Live Connect APIs enable Windows Phone 7.0, 7.5, and 8.0 apps to work with info in, Microsoft OneDrive, and other services that are compatible with Live Connect.

Note   If you're working on a mobile app that doesn't run on Windows Phone, this is not the topic you need. Go to Mobile and Windows desktop apps.
Tip  Before you can start coding Windows Phone apps, you need the right tools. For details, see Windows Phone Dev Center - Learn to build Windows Phone apps.

Before your Windows Phone app can use the Live Connect APIs, you'll need to get a client ID for it by configuring your app.

Important  When you configure your app and get its client ID, you must specify that you are configuring a mobile app. Mobile apps use a different OAuth 2.0 authentication flow. To do this, in the Live Connect app management site for your client ID, click Application Settings Page (or Edit settings, if you've already created your client ID), click API Settings, click Yes next to Mobile client app, and then click Save.

Live SDK compatibility

This table shows which Live SDK version runs on which Windows Phone version.

This version of the Live SDK ...Supports these Windows Phone versions

Live SDK V5.3

Windows Phone 7.5

Windows Phone 7.8

Windows Phone 8.0

Live SDK V5.2

Windows Phone 7.5

Windows Phone 7.8


Referencing the Live Connect APIs with C#

To reference the Live Connect APIs from a Windows Phone project in Microsoft Visual Studio 2010, do this:

  1. Install the Live SDK, if you haven't already done so.
  2. In your project, in Solution Explorer, right-click References > Add Reference.
  3. On the .NET tab, click Microsoft.Live.Controls, press and hold the CTRL key, and click Microsoft.Live.
  4. Click OK.
  5. Add the corresponding using statements to your code, like this.
    using Microsoft.Live;
    using Microsoft.Live.Controls;

If the Live Connect sign-in control doesn't appear in the Microsoft Visual Studio Toolbox, do this to add it:

  1. In your project, if the Toolbox is not visible, with the Extensible Application Markup Language (XAML) designer open, click View > Toolbox.
  2. Right-click a blank area of the Toolbox, and click Choose Items.
  3. Click Browse.
  4. Go to the Live SDK install folder. From there, go to the \Windows Phone <version>\References\ folder, where <version> is the Windows Phone version for which you are building the app, such as 7.5 for Windows Phone 7.5. Click Microsoft.Live.Controls.dll > Open > OK.
    Note  By default, the Live SDK is installed in the \Live\v5.0\ folder in \Program Files\Microsoft SDKs\ (on 32-bit computers) or \Program Files (x86)\Microsoft SDKs\ (on 64-bit computers).


Code sample

These code samples show the basic code that you need to:

  • Invite a user to sign in.
  • Get permission from signed-in users to access their basic profile info.
  • Greet signed-in users with their first and last names.

To run this code in your app, replace CLIENT_ID in the example with the client ID you got for your app by Configuring your app above.


    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True" xmlns:my="clr-namespace:Microsoft.Live.Controls;assembly=Microsoft.Live.Controls">
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <my:SignInButton Name="btnSignin" ClientId="CLIENT_ID" Scopes="wl.signin wl.basic" Branding="Windows" TextType="SignIn" SessionChanged="btnSignin_SessionChanged" HorizontalAlignment="Left"  VerticalAlignment="Top" />
        <TextBlock Height="32" HorizontalAlignment="Left" Margin="12,78,0,0" Name="infoTextBlock" Text="" VerticalAlignment="Top" Width="419" />


using System;
using System.Windows;
using System.Collections.Generic;
using Microsoft.Phone.Controls;
using Microsoft.Live;
using Microsoft.Live.Controls;

namespace WindowsPhoneCodeSample
    public partial class MainPage : PhoneApplicationPage
        private LiveConnectClient client;
        public MainPage()

        private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
            if (e.Status == LiveConnectSessionStatus.Connected)
                client = new LiveConnectClient(e.Session);
                LiveOperationResult operationResult = await client.GetAsync("me");
                    dynamic meResult = operationResult.Result;
                    if (meResult.first_name != null &&
                        meResult.last_name != null)
                        infoTextBlock.Text = "Hello " +
                            meResult.first_name + " " +
                            meResult.last_name + "!";
                        infoTextBlock.Text = "Hello, signed-in user!";
                catch (LiveConnectException exception)
                    this.infoTextBlock.Text = "Error calling API: " +
                infoTextBlock.Text = "Not signed in.";

To learn what this code does, see Core concepts and Identity (profiles).

For additional code examples, look throughout this documentation for subsections starting with "[C#]".


By default, any code example labeled for "[C#]" applies to both Windows Phone 8.0 apps and Windows Store apps using C#.

To learn how to apply the code examples throughout this documentation in the context of a larger reference code sample, see Working with the code examples.


Background transfer

Windows Phone 7.5 apps can start upload and download file requests with OneDrive that continue even if the app that started the request is suspended or quits. This feature is known as background transfer. For more info, see the "Downloading files" and "Uploading files" sections—specifically the tips following the Windows Phone portion of each section—in Folders and files.


Next steps

You can learn more about using the Live Connect APIs from these topics: