WebAuthenticationBroker & Facebook

April 19, 2013

I needed to use Facebook authentication in a Windows Store app the other day. The Windows Runtime makes this trivially easy with it’s WebAuthenticationBroker class. The web authentication broker allows apps to use Internet authentication and authorization protocols like OAuth and OpenID with minimal effort. Unfortunately the samples I found on the interwebs for Facebook were buggy/incomplete or assumed the I had a deep understanding of Facebook authentication. After a bit of work I was able to get it working and figured I’d share to save someone else some time.

AppID

Before you can authenticate against Facebook you need an AppID for your app. For obvious reasons, all of the documentation assumed you’re building a Web App but it is the same process.

  1. Head over to https://developers.facebook.com/apps and "Create a New App"
  2. Once it completes creating you app, copy your AppID from the next screen

Authentication Method

Next I created a new async method that authenticates the user and returns the Authentication Token from Facebook.