Windows Live ID in a Windows Phone 7 App

When building apps for Windows Phone 7, one of the most common requirements is allowing users to sign in using their Windows Live ID account. This enables seamless access to Microsoft services, user personalization, and secure identity verification.

If you’re interested in how mobile platforms shape user experience beyond just authentication, you may enjoy our breakdown 7 things your desktop envies from your mobile site, which explores how mobile design principles influence modern app development.

This guide walks you through the complete process of integrating Windows Live ID in a Windows Phone 7 App-covering setup, OAuth flow, callback handling, UI creation, and user-data access. Even if you’re new to WP7 development, you’ll be able to follow along easily.

Step 1: Setting Up Your Windows Live Application

Before coding your WP7 project, you must register your app through the Microsoft Developer Center.

✔ How to Register

  1. Sign in to the Microsoft Developer Portal.
  2. Navigate to App Management → Live Connect Applications.
  3. Create a new application entry.
  4. Provide the following:
    • App name
    • App description
    • Redirect domain
  5. Copy your Client ID—you’ll need this for OAuth authorization.

Why this matters

Windows Live authentication runs on OAuth 2.0, which requires Microsoft to identify your app before granting login access.

Step 2: Creating the WP7 Application

Open Visual Studio and create a new Windows Phone Application project.

Inside MainPage.xaml.cs, initialize variables for handling authentication:

private const string ClientID = "YOUR_CLIENT_ID";
private const string RedirectUrl = "https://login.live.com/oauth20_desktop.srf";
private string accessToken = string.Empty;

This sets up your app to request permissions and handle the returned authentication token.

Step 3: Building the Login UI

Create a simple interface:

Components to Add:

  • A Login button
  • A WebBrowser control for Microsoft’s sign-in page
  • A status message label

Your XAML might look like this:

<Button Content="Sign in with Windows Live" 
        x:Name="LoginButton" 
        Click="LoginButton_Click"/>

<WebBrowser x:Name="AuthBrowser" 
            Visibility="Collapsed" 
            Navigating="AuthBrowser_Navigating" />

When the user taps the login button, your app loads the Microsoft sign-in portal inside the WebBrowser control.

Step 4: Generating the Login URL

Now construct the OAuth request URL.

string loginUrl = 
    "https://login.live.com/oauth20_authorize.srf" +
    "?client_id=" + ClientID +
    "&scope=wl.basic%20wl.emails" +
    "&response_type=token" +
    "&redirect_uri=" + RedirectUrl;

AuthBrowser.Navigate(new Uri(loginUrl));
AuthBrowser.Visibility = Visibility.Visible;

What this URL does:

  • Requests user permission
  • Specifies which data your app can access
  • Defines how Microsoft returns the token
  • Opens the login UI

Step 5: Handling Windows Live OAuth Redirect

Once the user signs in, Windows Live redirects to your specified URL containing the access token.

Capture it inside the Navigating event:

private void AuthBrowser_Navigating(object sender, NavigatingEventArgs e)
{
    if (e.Uri.ToString().Contains("access_token"))
    {
        string fragment = e.Uri.Fragment;
        string tokenParam = fragment.Split('&')
                                    .First(x => x.Contains("access_token"));
        accessToken = tokenParam.Split('=')[1];

        AuthBrowser.Visibility = Visibility.Collapsed;
        StatusText.Text = "Login successful!";
    }
}
private void AuthBrowser_Navigating(object sender, NavigatingEventArgs e)
{
    if (e.Uri.ToString().Contains("access_token"))
    {
        string fragment = e.Uri.Fragment;
        string tokenParam = fragment.Split('&')
                                    .First(x => x.Contains("access_token"));
        accessToken = tokenParam.Split('=')[1];

        AuthBrowser.Visibility = Visibility.Collapsed;
        StatusText.Text = "Login successful!";
    }
}

What’s happening

  • WP7 intercepts the redirect
  • The access token is extracted
  • Browser UI is hidden
  • The user is now authenticated

Step 6: Displaying the Account Information

With the token ready, your app can query the Live Connect API.

Example request:

string requestUrl = 
    "https://apis.live.net/v5.0/me?access_token=" + accessToken;

WebClient client = new WebClient();
client.DownloadStringCompleted += (s, args) =>
{
    var result = args.Result;
    // Parse JSON data here
};
client.DownloadStringAsync(new Uri(requestUrl));

You can now retrieve:

  • Name
  • Email
  • Locale
  • User ID

Perfect for customizing user experiences.

Step 7: Accessing Extended Windows Live Data

If your app requires deeper integration, such as accessing contacts or calendars, update your permissions.

Example scopes:

  • wl.contacts_emails
  • wl.calendar
  • wl.birthday

Modify your login URL accordingly:

"&scope=wl.basic%20wl.emails%20wl.contacts_emails"

Each additional permission may prompt the user for approval, following Microsoft’s security guidelines.

Bonus: Improving UX in WP7 Authentication Flow

To create a smoother sign-in experience:

✔ Add a loading animation during WebBrowser navigation

✔ Show error handling for invalid tokens

✔ Allow users to log out (clear stored token)

✔ Save the token securely using IsolatedStorageSettings

This enhances your app’s professional feel and ensures a more stable experience.

Integrating Windows Live ID into a Windows Phone 7 application isn’t just useful-it unlocks the ability to build personalized, secure, and connected mobile experiences.

You’ve now learned how to:
✔ Register your app
✔ Build the login interface
✔ Use OAuth for authentication
✔ Capture and store access tokens
✔ Retrieve user information

With these steps, you can confidently add Microsoft-powered sign-in to your WP7 projects and extend features through Live Connect APIs.