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.
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.
- Head over to https://developers.facebook.com/apps and “Create a New App”
- Once it completes creating you app, copy your AppID from the next screen
Next I created a new async method that authenticates the user and returns the Authentication Token from Facebook.