I’ve written a XAML-based WinRT app that connects to foursquare via the WebAuthenticationBroker.AuthenticateAsync call. Here’s the auth code:
public async Task<string> FsqAuthenticate()
{
var fsqAuthUrl = string.Format(
"https://foursquare.com/oauth2/authenticate?client_id={0}&response_type=code&redirect_uri={1}&display=webpopup",
ClientId, RedirectUri);
var requestUri = new Uri(fsqAuthUrl, UriKind.RelativeOrAbsolute);
var redirUri = new Uri(RedirectUri, UriKind.RelativeOrAbsolute);
string authCode = string.Empty;
string authToken = string.Empty;
try
{
ResponseErrorMsg = string.Empty;
WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
requestUri, redirUri);
if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
This works fine if the user chooses to authenticate directly through foursquare, or sign up through foursquare. However, the foursquare OAuth page gives the user the option of logging in/signing up via Facebook. If selected, the initial Facebook login screen displays correctly; the user can enter a username/password and select the ‘log in’ button; then the window goes blank. It appears control is being passed off to Facebook’s popup prompting for permissions to be granted. However, the WebAuthenticationBroker is not displaying this. For all intents and purposes, WebAuthenticationBroker is hung.
Does there exist a workaround for this behavior?
I was able to get a response from Microsoft on this issue at last:
The upshot is, there is no workaround, short of coding your own login process and bypassing the WebAuthenticationBroker entirely (which I ended up doing).
TL;DR: WebAuthenticationBroker is broken, and there are no plans to fix it at this time.