简体   繁体   English

Azure 移动服务客户端登录返回身份验证错误 (401)

[英]Azure mobileserviceclient login returns authentication error(401)

I currently have a login flow with facebook that is working 100% and I just added Google into the equation.我目前在 facebook 上有一个 100% 的登录流程,我刚刚将 Google 添加到了等式中。 I wrote the code so that my google provider tokens are formatted and cached in the same way as my facebook tokens.我编写了代码,以便我的 google provider 令牌以与我的 facebook 令牌相同的方式进行格式化和缓存。 My code gets the facebook and google tokens and does the folling: (the following example is for the google login):我的代码获取 facebook 和 google 令牌并执行以下操作:(以下示例用于 google 登录):

        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:然后,在我的身份验证方法中,这是我如何使用 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.问题是 Facebook 可以正常工作,而 Google 生成了未经授权的 401。 The specific error I get (before the future returns failed), is: W/DefaultRequestDirector: `Authentication error: Unable to respond to any of these challenges: {}.我得到的具体错误(在未来返回失败之前)是:W/DefaultRequestDirector:`身份验证错误:无法响应任何这些挑战:{}。 Azure logs show that it is a 401 unauthorized. Azure 日志显示这是未经授权的 401。

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.在尝试使用它们之前,我成功地打印了 Google-Sign-In 令牌并以与我的 facebook 令牌相同的方式对其进行了格式化。 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).我已经重新生成了一次,我尝试将原点设置为 https,我尝试了不同的键组合,我什至摆脱了我的 google-services.json(显然不需要)。 I did not use the client key that was generated on this google doc .我没有使用在这个 google doc上生成的客户端密钥。

Another question here is how does the authentication settings of my Azure Mobile App come into play?这里的另一个问题是 Azure 移动应用程序的身份验证设置如何发挥作用? 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.在从 MobileService 迁移到 MobileApp 之前,我最初配置了我的 facebook,现在我不需要使用“交钥匙身份验证”功能来让它工作。 I went ahead and entered my app key and secret for facebook, but it definitely works regardless of whether or not this is enabled.我继续为 facebook 输入了我的应用程序密钥和机密,但无论是否启用它,它都可以正常工作。 Is this a necessary feature for oauth?这是 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.此外,根据登录时的令牌格式和身份验证功能的开/关状态, W/DefaultRequestDirector: Authentication error: Unable to respond to any of these challenges: {} ,将在大括号中包含一些文本关于天蓝色的端点。

Thank you so much if you can help.如果您能提供帮助,非常感谢。 Such a picky issue here.这么挑剔的问题在这里。

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 .对于 facebook,那就是MS_FacebookAppIDMS_FacebookAppSecret For Google, that's MS_GoogleClientID and MS_GoogleClientSecret .对于 Google,这是MS_GoogleClientIDMS_GoogleClientSecret

For reference, check out https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-migrating-from-mobile-services/#authentication如需参考,请查看https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-migrating-from-mobile-services/#authentication

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM