none
Azure Mobile Services Authentication Broken For Windows Phone 8.1

    Pregunta

  • I created a universal app using the new Visual Studio 2013 Update 2 RC that supports universal apps and Windows Phone 8.1. I have tried doing authentication using the Azure Mobile Services NuGet package and am seeing broken behavior. After testing, I see that this same example works for Windows Phone 8 and Windows 8 Store apps.

    In case it is important, I am using the new .Net backend for my mobile service. I have made sure that all of my settings for my 3rd party apps (Google, Twitter, etc.) are set correctly since things like the redirect or callback URLs are different when using .Net backends.

    My code looks like this:

    private async void Button_Click( object sender, RoutedEventArgs e )
          {
             try
             {
                var mobileService = new MobileServiceClient( "https://myservice.azure-mobile.net/", "<SecretSecretSecret>" );
                var login = await mobileService.LoginAsync( MobileServiceAuthenticationProvider.Google );
                var m = new MessageDialog( String.Format( "{0} {1}", login.UserId, login.MobileServiceAuthenticationToken ), "Title" );
                await m.ShowAsync();
             }
             catch ( Exception ex)
             {
                var m = new MessageDialog(ex.Message,"Exception");
                m.ShowAsync();
             }
          }

    On the Windows Phone 8.1 emulator, The LoginAsync() method is called and I am prompted to login to Google. Once I login successfully, the next line of code (creating the MessageDialog) is never executed. A breakpoint there is never hit. A breakpoint in the exception is also never hit, so it appears that no exception is being thrown. The app doesn't crash or anything though. My UI is re-shown after attempting to login and I can reproduce the issue again without redeploying or restarting the app.

    On a real Windows Phone 8.1 device, I see almost the exact same behavior except that I am never even prompted to login. I just click the button and nothing happens. If I click the button again, it says that an authentication is already in progress. Again, the next line of code is never called, and it appears that no exception is thrown.

    I know that Windows Phone 8.1 and the Visual Studio 2013 Update 2 are only release candidates right now, so I'm not surprised to see some bugs. It is unfortunate that mobile services are basically unusable right now though if your app needs authentication at all.

    Any ideas for a workaround? Should I just try to submit this as a bug or is there a way to find out if it is already a known issue?


    jueves, 24 de abril de 2014 6:40

Respuestas

  • Brett,

    Your issue may be covered in this other thread.

    http://social.msdn.microsoft.com/Forums/windowsazure/en-US/95c6569e-2fa2-43c8-af71-939e006a9b27/mobile-services-loginasync-remote-procedure-call-failed-hresult-0x800706be?forum=azuremobile

    Phillip was advising us to call a new method (see below) for WP8.1 universal apps that I believe relieves this problem.  Read the thread, his advice about half way down which contains this code snip:

    protected override void OnActivated(IActivatedEventArgs args)
            {
                base.OnActivated(args);
    
    #if WINDOWS_PHONE_APP
                if (args.Kind == ActivationKind.WebAuthenticationBrokerContinuation)
                {
                    App.<mobileservice>.LoginComplete(args as WebAuthenticationBrokerContinuationEventArgs);
                }
    #endif
            }

    jueves, 24 de abril de 2014 20:10
  • The behavior described (promise is never finished) would result from not doing the above code in your win phone 8.1 app.  Calling LoginComplete() will resolve the promise we gave you in LoginAsync(), letting that code continue. 

    • Marcado como respuesta Brett Lesnau viernes, 25 de abril de 2014 3:08
    jueves, 24 de abril de 2014 22:48
    Moderador

Todas las respuestas

  • Brett,

    Your issue may be covered in this other thread.

    http://social.msdn.microsoft.com/Forums/windowsazure/en-US/95c6569e-2fa2-43c8-af71-939e006a9b27/mobile-services-loginasync-remote-procedure-call-failed-hresult-0x800706be?forum=azuremobile

    Phillip was advising us to call a new method (see below) for WP8.1 universal apps that I believe relieves this problem.  Read the thread, his advice about half way down which contains this code snip:

    protected override void OnActivated(IActivatedEventArgs args)
            {
                base.OnActivated(args);
    
    #if WINDOWS_PHONE_APP
                if (args.Kind == ActivationKind.WebAuthenticationBrokerContinuation)
                {
                    App.<mobileservice>.LoginComplete(args as WebAuthenticationBrokerContinuationEventArgs);
                }
    #endif
            }

    jueves, 24 de abril de 2014 20:10
  • The behavior described (promise is never finished) would result from not doing the above code in your win phone 8.1 app.  Calling LoginComplete() will resolve the promise we gave you in LoginAsync(), letting that code continue. 

    • Marcado como respuesta Brett Lesnau viernes, 25 de abril de 2014 3:08
    jueves, 24 de abril de 2014 22:48
    Moderador
  • Thank you very much Rob and Phillip. That cleared up all of the issues that I was currently having. I'm just curious though, was there information somewhere that should have led me to this answer besides finding the other forum post that was pointed out? I know a lot of this stuff is new, so documentation is not completed, but I just want to make sure that I know where to look for information before asking more questions on the forums.
    viernes, 25 de abril de 2014 3:10