0

I am trying to use Google Authentication in my Xamarin Forms app by using Xamarin.Auth to perform client-side authentication and then passing the received token to my Azure App Service custom website back-end that is configured to use Google Authentication.

I get the tokens back from Xamarin.Auth on the client just fine. However, when I try to use the MobileServiceClient's LoginAsync method, I get an Exception that says:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

I found this post: Xamarin MobileServiceClient RefreshUserAsync with Google 403 , in which rleffler apparently has this working, but I don't think I can direct message him.

Here is my code calling LoginAsync:

MobileServiceClient client = new 
MobileServiceClient("http://<mywebsite>.azurewebsites.net");

            var zumoPayload = new JObject();
            zumoPayload["access_token"] = accessToken;
            zumoPayload["id_token"] = idToken;

            if (user == null)
            {
                string message;
                try
                {
                    user = await client.LoginAsync(MobileServiceAuthenticationProvider.Google, zumoPayload);
                    message = string.Format("You are now logged in - {0}", user.UserId);
                }
                catch (Exception ex)
                {
                    //This is where I catch the JsonReaderException
                    message = "You must log in. Login Required";
                }
            }
  • I am facing the same issue. Today i created a new application in azure and i am facing this issue. But my old application is working fine with same code. Instead of google i am using WindowsAzureActiveDirectory for login. Did you find the solution ? – Basit ZIa Oct 26 '17 at 12:29
  • Hi. Nope, no progress. I have posted onto this thread though: https://github.com/Azure/azure-mobile-apps-net-client/issues/369 . Maybe if you post there it will get higher in the Microsoft rep's queue? I decided to go with server-login for now. I'll loop back on this down the road and then hopefully Microsoft documentation will be updated. – Kenon Ronz Oct 30 '17 at 16:48
  • thanks for reply. I made 2,3 changes and that fixed the issue for me. I am not exactly sure which step fixed it. Most probably changing "http" to "https" fixed it and now every things work fine. Client = new MobileServiceClient("h t t p s://xxxxx-dev.azurewebsites.net"); If this fixes your issue let me know. i will add it as an answer – Basit ZIa Oct 31 '17 at 09:23

0 Answers0