With the recent release of our developer platform we’ve made it easy for developers on modern mobile platforms such as Windows Phone, Android, and iOS to easily integrate the ability for users to access their information such as contacts and photos from Hotmail, Messenger, and SkyDrive in their favorite mobile apps and devices.

We’ve streamlined the process for doing this in the following ways:

  • Lightweight application setup process which requires no server-side code.
  • Mobile optimized sign-in and user consent experiences
  • Providing code samples which illustrate the key steps in building a mobile application that access a user’s cloud data

Lightweight application setup process

One key thing we learned from our previous releases is that developers of mobile applications often do not have web services backing their applications. This means that any process we had that requires an application to communicate with our various authorization and web service end points would need to be enabled for client-side applications.

Today, our registration process at http://manage.dev.live.com is extremely lightweight. The only information required to create an application is the name and language of the application, as shown below:

Registration at manage.dev.live.com

Once you click I accept, you are provided with a client ID and client secret.

Those familiar with OAuth 2.0 may notice that a step appears to be missing: providing the URL the user is redirected to after they have successfully logged in and granted access to your application to access their data. This step is now optional. Web-based applications can still provide this data on our application management site.

Mobile and desktop applications that do not have a website that the user can be redirected to should instead use https://oauth.live.com/desktop as their redirect URL when making OAuth 2.0 authorization requests. This URL should not be provided as the redirect URL for the mobile application in the application management site since it will be rejected.

Mobile optimized sign-in and user consent experiences

As mentioned in my previous blog post, we’ve built mobile optimized user experiences for users signing in and granting permission to applications to access their data.

We’ve created a code sample which shows how to access a user’s SkyDrive photo albums from Windows Phone and is available to download from the MSDN code sample gallery. The code sample shows the key steps an application has to go through to sign in the user, get permission to access their data, and then actually access the user’s information as well as the related user experiences.

The process of signing in the user requires the application to construct a URL to our OAuth 2.0 authorization end point and request the appropriate scopes required to access the data the application is interested in. The code looks like this:

/// <summary>
/// The URI for the OAuth service's Authorize endpoint.
/// </summary>
private static readonly string OAuthAuthorizeUri = "https://oauth.live.com/authorize";

/// <summary>
/// The list of scopes.
/// </summary>
private string[] scopes = new string[] { "wl.basic", "wl.photos" };

/// <summary>
/// Build the OAuth URI.
/// </summary>
/// <param name="scopes">The requested scopes.</param>
/// <returns>The OAuth URI.</returns>
private Uri BuildOAuthUri(string[] scopes)
{
List<string> paramList = new List<string>();
paramList.Add("client_id=" + HttpUtility.UrlEncode(MainPage.ClientId));
paramList.Add("scope=" + HttpUtility.UrlEncode(String.Join(" ", scopes)));
paramList.Add("response_type=" + HttpUtility.UrlEncode("token"));
paramList.Add("display=" + HttpUtility.UrlEncode("touch"));
paramList.Add("redirect_uri=" + HttpUtility.UrlEncode(MainPage.RedirectUri));

UriBuilder authorizeUri = new UriBuilder(MainPage.OAuthAuthorizeUri);
authorizeUri.Query = String.Join("&", paramList.ToArray());
return authorizeUri.Uri;
}

When the constructed URL is navigated to in a browser, the end user goes through the following user experience. First they are asked to sign in.

Windows Live sign in screen

After signing in, the user is shown a permission dialog where they are asked for consent to grant the application access to their basic information and SkyDrive photos, which the application requested.

"Allow access?" screen

Once the user completes these flows, the application gets back an access token which can then be used in combination with our REST APIs to access the user’s data. It should be noted that the permission granting step only has to occur once, after which the application has access to the user’s data until the user decides to revoke access to their data by visiting our consent management page.

In this particular code sample, the application simply lists the user’s profile information and SkyDrive photo albums.

Profile info and albums

More Code Samples to Come

We’ve gotten a lot of feedback that developers would like to see more code samples that show how to access data from Hotmail, Messenger, and SkyDrive from their favorite programming languages and platforms. Rest assured that your feedback has been heard, and we’re working on providing a larger breadth of code samples as we speak. For now, mobile developers can download the SkyDrive API example from this article to get started.

Thanks again for all the feedback, and please keep it coming.

Dare Obasanjo – Lead Program Manager, Messenger Connect Platform