In a recent project I had to implement Google login to an Universal App. I decided to use the native WebAuthenticationBroker control and the implementation was not as straightforward as I hoped. By implementing Google login I mean getting the authentication token that you can then use with your server API.
WebAuthenticationBroker is a good idea but it is implemented rather poorly. It works differently on Windows 8.1 and Windows Phone 8.1 due to the “AndContinue” pattern that Windows Phone 8.1 forces on you. You can solve this with some ifdefs and platform specific code, as always.
The real problem s that the MSDN sample states it works with Google login but it does not. The sample thinks it gets the authentication token but it does not, it just gets the success code that you have to exchange for the authentication token yourself.
Lets start with a basic config
The important things here are your Google app id and Google app secret. The GoogleStartUri also contains permissions that you want to get (profile, https://www.googleapis.com/auth/plus.login and https://www.googleapis.com/auth/plus.me email in my case).
You use this config with a WebAuthenticationBroker call
on Windows 8.1 you get the response data immediately. On Windows Phone 8.1, you have to implement the “AndContinue” pattern.
You use the response data to parse out the success code
Now that you have the success code, you can exchange it for the authentication token
And now you finally have a way to get the authentication token and implement Google login.