none
Mobile Services LoginAsync - Remote Procedure Call Failed (HRESULT: 0x800706BE)

    Question

  • Hi guys,

    I've upgraded VS2013 so I can start testing out development on Windows Phone 8.1. So far so good. I've created a Windows Phone 8.1 project and that works perfectly in the emulator, and I've also created an Azure Mobile Service (.NET backend) that I have deployed to Azure. So far it all works.

    The problem occurs when I try to authenticate using the LoginAsync method (I'm following the Mobile Services authentication tutorial); it throws me an exception and I can't seem to figure out why. This occurs on both the emulator and on a device. Is there something I am missing? Note: The Mobile Service is published right from the Create new -> Mobile Service template.

    "The remote procedure call failed. (Exception from HRESULT: 0x800706BE)"

    "

       at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAndContinue(Uri requestUri, Uri callbackUri, ValueSet continuationData, WebAuthenticationOptions options)
       at Microsoft.WindowsAzure.MobileServices.AuthenticationBroker.AuthenticateWithBroker(Uri startUrl, Uri endUrl, Boolean useSingleSignOn)
       at Microsoft.WindowsAzure.MobileServices.AuthenticationBroker.AuthenticateAsync(Uri startUrl, Uri endUrl, Boolean useSingleSignOn)
       at Microsoft.WindowsAzure.MobileServices.MobileServiceUIAuthentication.LoginAsyncOverride()
       at Microsoft.WindowsAzure.MobileServices.MobileServiceAuthentication.<LoginAsync>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at TestWP81.MainPage.<Authenticate>d__3.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at TestWP81.MainPage.<OnLoaded>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)
       at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()"
    Tuesday, April 15, 2014 7:16 AM

Answers

  • I forgot to mention, that our tutorials are not yet updated for window phone 8.1, so you will also need to add the following code as well into your app.xaml.cs (this snippet is for a univeral app, phone 8.1 would be the same just without needing it to be conditional)

            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
            }


    Saturday, April 19, 2014 7:28 PM
    Moderator
  • The redirect URL's required when using a MicrosoftAccount with the "Enhanced redirection security:" set to true are different between the .NET and Node.js backends currently.  However, I do not believe this is related to the original issue here.  

    I have confirmed that calling LoginAsync() on WP8.1 from onNavigatedTo or the page's loaded event (as shown in the auth tutorials for Windows Store and Windows Phone 8) cause the error shown:

    (the remote procedure call failed. (Exception from HRESULT: 0x800706BE) at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAndContinue)...

    If you do not need to log in during these events, the quickest way to address this is to move your login outside of one of these two places, and instead have it initiated after the UI is shown for your application.  (User clicks a login button say)

    In the meantime, I'll see if I can get a code snippet that will allow login to work from these two locations to show how to workaround this until we identify the core issue.

    Saturday, April 19, 2014 7:23 PM
    Moderator

All replies

  • I have this problem too. I'm working with a shared app, and it works fine when running for Windows 8.1, but when I try to run it on Windows Phone 8.1 I get the exact same error as above.

    Tuesday, April 15, 2014 5:43 PM
  • What function are you calling LoginAsync from?  Are you following the phone 8 auth tutorial?
    Thursday, April 17, 2014 7:16 AM
    Moderator
  • Yeah, I am following the authentication tutorial to the point :) It seems to throw an exception when awaiting LoginAsync. Doesn't seem to matter where I put it, in the OnNavigatedTo method, or Loaded method or not unfortunately. 
    Thursday, April 17, 2014 7:30 AM
  • I'm also experiencing this issue. It was working on Windows Phone 8 before I upgraded the project to Windows Phone 8.1. I too am using a universal app.

    Saturday, April 19, 2014 2:00 AM
  • Ok, I *MAY* have figured this out.

    If your mobile service is using .NET C# instead of JavaScript, the Redirect URL should instead be <a href="https://.azure-mobile.net/signin-microsoft">https://<mobileservicename>.azure-mobile.net/signin-microsoft. After doing this I was successful at getting it to work.

    Evidentially the documentation was written for JavaScript. .NET is still undocumented.

    Saturday, April 19, 2014 2:45 AM
  • I have exactly the same problem.

    I'm connecting to an existing node.js backed web service.  I've added the wp8.1 project to convert to a universal app.  The Windows8 app still works as before--no changes made and no problems encountered.

    In the WP8.1 app, I can call Mobile Services API calls that are configured for "anyone with app key" (no user auth).  So I know mobile services and my mobile app actually do work.

    But when I make this call:

    await MobileService.LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);

    I get the same "Remote procedure call failed 0x800706BE" error posted by Henning above.

    Made a change to authenticationprovider .MicrosoftAccount, same problem.

    Just for kicks, I created a new WP 8.0 Silverlight app, pasted in the same code, and it works fine.  It has something to do with the universal app and the phone client.

    Saturday, April 19, 2014 2:58 PM
  • I hope you found a workaround that works for me too!

    FWIW, my back-end is JavaScript, and I have the same problem.

    Can you be more specific on the change you made to get your workaround to work? 

    My authentication call is:

    await MobileService.LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);

    I think I'm just not familiar with the technique you're using to manipulate the redirect URL in your code, and I'm not sure which documentation you're referencing to noodle through it.

    Encouraging news, though, thanks for posting this!

    Saturday, April 19, 2014 3:01 PM
  • The redirect URL's required when using a MicrosoftAccount with the "Enhanced redirection security:" set to true are different between the .NET and Node.js backends currently.  However, I do not believe this is related to the original issue here.  

    I have confirmed that calling LoginAsync() on WP8.1 from onNavigatedTo or the page's loaded event (as shown in the auth tutorials for Windows Store and Windows Phone 8) cause the error shown:

    (the remote procedure call failed. (Exception from HRESULT: 0x800706BE) at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAndContinue)...

    If you do not need to log in during these events, the quickest way to address this is to move your login outside of one of these two places, and instead have it initiated after the UI is shown for your application.  (User clicks a login button say)

    In the meantime, I'll see if I can get a code snippet that will allow login to work from these two locations to show how to workaround this until we identify the core issue.

    Saturday, April 19, 2014 7:23 PM
    Moderator
  • I forgot to mention, that our tutorials are not yet updated for window phone 8.1, so you will also need to add the following code as well into your app.xaml.cs (this snippet is for a univeral app, phone 8.1 would be the same just without needing it to be conditional)

            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
            }


    Saturday, April 19, 2014 7:28 PM
    Moderator
  • Hi

    The issue here is that you should not call the Loginasync from the loaded event or constructor.

    If you can move the code to some other event, then the call succeeds irrespective of Phone 8/8.1.

    I also faced same issue and it is working for me now.

    Regards



    Varun Ravindranath Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you.

    Tuesday, April 22, 2014 2:29 AM
  • Thanks, Phillip, your two messages are both very helpful!

    Indeed if I call the LoginAsync after the form is displayed I get a proper redirect to the aad login form, so it's one step closer.

    I also found quickly why "LoginComplete" must be important--because my code never resumes after await LoginAsync, and at some point I get redirected again and have a "login in progress" error.

    But maybe I'm not configured correctly, because as far as I can tell Microsoft.WindowsAzure.MobileServices.MobileServiceClient has no LoginComplete method. Intellisense doesn't find it, and if I just ignore that and try to compile I get method not found error.

    When I NuGet'ed the mobile services client for the WP8.1 project of the universal app solution, it obtained Mobile version 1.2.1 (appears the same as for the Win8.1 app).  Do I have the wrong version somehow, and if so can I obtain a newer one elsewhere? 

    Wednesday, April 23, 2014 6:09 AM
  • 1.2.1 is correct, however LoginComplete() is only available on the WP8.1 platform, source for definition here:

    https://github.com/Azure/azure-mobile-services/blob/master/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices.WindowsPhone81/Extensions/MobileServiceClientExtensions.cs#L45

    Can you verify the nuget installed on the windows phone 8.1 project in the universal app has 1.2.1 and has the mobile services ext dll referenced pointing to the wpa81 folder?  If not, try uninstalling/reinstalling the nuget to see if it fixes itself.

    Wednesday, April 23, 2014 6:23 AM
    Moderator
  • I did uinstall/reinstall using nugget just to be sure.  I got the LoginComplete in the App class, and my login process is working normally now. Thanks!

    Not super ideal to have to wait until after the UI is loaded to trigger a login, since my main screen options are per user depending on their authorization level, but it'll be OK for now.

    Thanks Phillip!

    Friday, April 25, 2014 2:20 AM
  • Hi Philip,

    Thanks for the replies, and yes, it seems to work if I attach the Login-procedure to an event that is triggered after app and the UI is up and running (e.g a button).

    Any idea on why this error occurs and why it behaves differently? :)

    • Proposed as answer by Ozzy1873 Sunday, July 20, 2014 9:00 PM
    • Unproposed as answer by Ozzy1873 Sunday, July 20, 2014 9:00 PM
    Friday, April 25, 2014 7:19 AM
  • In the scenario where you want to the login to appear ASAP, without waiting for the user to press a button, etc on the UI, what works for me is to defer the call to LoginAsync until after the page load sequence completes (after the Loaded event has finished its processing).  I do so by using a technique similar to using the JavaScript setTimeout(fn, 0) or the older PostMessage Win32 technique.  Basically, add a handler for the Page Loaded event that uses the Dispatcher to defer the execution of the call:

    public MainPage()
    {
        InitializeComponent();
    
        Loaded += async (sender, args) =>
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, RefreshTodoItems);
        };
    }
    

    This effectively schedules the call to RefreshTodoItems (which in my example case contains the call to LoginAsync) as the next thing to be handled by the UI thread.  But because the Loaded event and the related functionality that called it is (are?) happening on that thread, the call to RefreshTodoItems waits for that to complete before it executes.  Not exactly "pleasant", but effective nonetheless. 

    • Proposed as answer by Nivelo1 Sunday, September 28, 2014 7:31 PM
    Monday, May 26, 2014 10:59 PM