2
votes

I currently have a login flow with facebook that is working 100% and I just added Google into the equation. I wrote the code so that my google provider tokens are formatted and cached in the same way as my facebook tokens. My code gets the facebook and google tokens and does the folling: (the following example is for the google login):

        USER_GOOGLE_TOKEN = new JsonObject();
        USER_GOOGLE_TOKEN.addProperty("access_token", accessToken);
        cacheProviderToken(USER_GOOGLE_TOKEN.toString());
        setCurrentProvider("google");

Then, in my authentication method in the activity, here is how I mobileserviceclient.login:

 MobileServiceAuthenticationProvider provider = null;
        if (getCurrentProvider().equals("facebook")){
            provider = MobileServiceAuthenticationProvider.Facebook;
        } else if (getCurrentProvider().equals("google")) {
            provider = MobileServiceAuthenticationProvider.Google;
        }


        token.addProperty("access_token", googleToken);
        ListenableFuture<MobileServiceUser> mLogin = mClient.login(MobileServiceAuthenticationProvider.Google, getProviderToken());

The problem is that Facebook works and Google produces a 401 unauthorized. The specific error I get (before the future returns failed), is: W/DefaultRequestDirector: `Authentication error: Unable to respond to any of these challenges: {}. Azure logs show that it is a 401 unauthorized.

I am successfully printing the Google-Sign-In token and formatting it in the same way as my facebook tokens before trying to use them. Are my google keys wrong? I regenerated them once already and I tried setting origions to https, I tried different key combos, and I even got rid of my google-services.json(apparently its not needed). I did not use the client key that was generated on this google doc.

Another question here is how does the authentication settings of my Azure Mobile App come into play? I had originally configured my facebook before migrating from a MobileService to MobileApp, and now I do not need to use the "turnkey authentication" feature for it to work. I went ahead and entered my app key and secret for facebook, but it definitely works regardless of whether or not this is enabled. Is this a necessary feature for oauth?

Also, Depending on the token format on Login and the On/Off status of the AUthentication feature, the errror: W/DefaultRequestDirector: Authentication error: Unable to respond to any of these challenges: {} , will have some text in the curly brackets about the azure endpoint.

Thank you so much if you can help. Such a picky issue here.

1
Can you elaborate the last one - about azure endpoint? That error is basically 401, and should not have nothing with the Azure.Alex Belotserkovskiy
In mobile app authentication, when I set the setting, "what to do when not authenticated", the curly braces contain information about "bearers". I also have some new information for you. Last night I went into the classic portal and saw the Facebook strings from when I set up authentication under the Identity tab of the mobile service. I Tried hard coding the Google values in the configure area next to the Facebook values since the identify tab is gone. It did not work despite disabling mobile app Auth.user2355058

1 Answers

2
votes

The App Service Authentication / Authorization is incompatible with a migrated Mobile Service and must remain off.

To update Authentication settings with a migrated Mobile Service, you set the app settings. For facebook, that's MS_FacebookAppID and MS_FacebookAppSecret. For Google, that's MS_GoogleClientID and MS_GoogleClientSecret.

For reference, check out https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-migrating-from-mobile-services/#authentication