Two days ago I published a sample app for Windows Phone 8 that demonstrates how to authenticate users and make calls against the REST API using the Salesforce Toolkits for .NET. The next obvious step was to build a sample application for Windows 8. ACHIEVEMENT UNLOCKED!

Windows 8 Sample App

You can get the sample here:

To get authentication working in Windows 8 we’ll use the WebAuthenticationBroker, which manages the asynchronous authentication operation in a modal dialog window. First, the user is asked to login. This is nothing more than secured browser control that renders the Salesforce login page.


Once the login information has been added, the user is then asked to authorize the application.


When this process completes, the user is returned back to the application. Programmatically we now have access to all the information returned to us from Salesforce. (Review this article if you need a refresher.)

Here’s the code. When setting up your Connected App you can use the same directions I detailed in this post. Also, be sure to grab the DeveloperForce.Common NuGet package.

A few important details to point out.

  • [Line 8]: As of the writing of this post, you have to use the DisplayTypes.Popup display type instead of DisplayTypes.Touch. While the rendering isn’t ideal for the modal dialog it’s better than simply not working (which is what will happen if you use DisplayTypes.Touch).

  • [Line 11]: Be sure to copy your Callback Url exactly as the WebAuthenticationBroker will look for this URI and only break when it finds it.

  • [Line 28]: In addition to the access_token, refresh_token, and instance_url you can also get the id, signature, issued_at, and (if you passed it with your URL) state.

This is just the start for the Windows 8 sample. We’ll add other features (such as refreshing the token and storing tokens securely) in the near future.

I hope this helps!

comments powered by Disqus