Windows Live Data is the API you use for delegated access to your user’s personal data like contacts. It’s a pretty simple API, however that hasn’t stopped me writing some components for it! Today, I’m releasing them publicly.
Not only do these components make it easier to work with the API, but they also provide an abstraction layer so that as the API develops your application doesn’t necessarily have to.
(Note: This post assumes an understanding for the Windows Live Data API. If you’ve never touched it before, read this first.)
First up is the PermissionRequestHyperLink control. Placing this on your page gives you a nice designer experience for building those yucky URLs and setting all the right flags.
A basic request looks something like this:
<live:PermissionRequestHyperLink id=”PermissionRequestHyperLink1″ runat=”server” Permission=”LiveContacts_ReadOnly” PrivacyUrl=”~/WindowsLive/PrivacyPolicy.aspx” ReturnUrl=”~/WindowsLive/ResponseHandler.ashx”>Permission Request</live:permissionrequesthyperlink>
And gives you designer experience like this:
Next up is the response handler base class. Start by adding a new ‘generic handler’ to your project:
Change the generated class to inherit from PermissionResponseHandler instead of IHttpHandler, then implement the ProcessResponse and ProcessFailure methods like so:
public class ResponseHandler : PermissionResponseHandler
{
protected override void ProcessResponse(HttpContext context, PermissionResponse response)
{
//Do something here like storing the token for future use
//response.DomainAuthenticationToken
//response.OwnerHandle
}protected override void ProcessFailure(HttpContext context, PermissionResponseCode responseCode)
{
//Perform some nice handling here
//responseCode
}
}
How easy is that!
You can grab the code from http://svn.fueladvance2.com/FuelAdvance.Components/trunk/ (username: anonymous). You’ll find the components in the FuelAdvance.Components.Web.WindowsLive namespace.
If you’re using Subversion yourself, remember that you can configure this as an svn:external and then you’ll always be running the latest version.
Next up, I’ll probably be releasing some managed wrappers for the Windows Live Contacts API.
Update 9/8/07: Change SVN link to point at the solution instead of the project.