Mike
Mike

Reputation: 662

Authentication issues with Azure Mobile Service for Windows Phone

I am attempting authentication with Google using Azure Mobile Service's Authentication Providers. I have followed the tutorial in the documentation (http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-phone-get-started-users/) and have applied it to my app's login screen. It does show a login prompt for Google, and I enter credentials and click sign in. Then instead of asking for consent to use my account details like expected, it goes back to my app's login screen.

I'm not sure what's wrong, or how to figure out what's wrong. I am somewhat new to Windows Phone development, and development in Visual Studio at all, being more used to Android development and Eclipse. This is new to me, and I'm lost.

Here's the code I use for Google authentication.

private async System.Threading.Tasks.Task aaGoogle()
{
    while (user == null)
    {
        string message;
        try
        {
            user = await App.MobileService
                .LoginAsync(MobileServiceAuthenticationProvider.Google);
            message = string.Format("You are now logged in - {0}", user.UserId);
        }
        catch (InvalidOperationException)
        {
            message = "You must log in. Login Required";
        }

        var dialog = new MessageDialog(message);
        dialog.Commands.Add(new UICommand("OK"));
        await dialog.ShowAsync();
    }
}

Upvotes: 0

Views: 546

Answers (1)

Mike
Mike

Reputation: 662

Ah, Microsoft's documentation is incomplete. I'm using a .NET backend and C# for my app, and the default callback URLs are made for the Javascript backend. So the correct callback URLs for the .NET backend are:

  • [mobileservice].azure-mobile.net/signin-twitter
  • [mobileservice].azure-mobile.net/signin-facebook
  • [mobileservice].azure-mobile.net/signin-google
  • [mobileservice].azure-mobile.net/signin-microsoft

After changing the links to those for all of the relevant services, the login screens and consent screens worked perfectly, and I got the login details for each account. Everything works as intended. I hope this helps someone else.

Upvotes: 1

Related Questions