简体   繁体   English

Azure应用服务Google身份验证

[英]Azure app service Google authentication

I have successfully create a simple android application that successfully logs into Google using an Azure app service. 我已经成功创建了一个简单的Android应用程序,该应用程序使用Azure应用程序服务成功登录了Google。

ListenableFuture<MobileServiceUser> mLogin = mClient.login(MobileServiceAuthenticationProvider.Google);

    Futures.addCallback(mLogin, new FutureCallback<MobileServiceUser>() {
        @Override
        public void onFailure(Throwable exc) {
            createAndShowDialog(exc.toString(), "Error");
        }
        @Override
        public void onSuccess(MobileServiceUser user) {
            createAndShowDialog(String.format(
                    "You are now logged in - %1$2s",
                    user.getUserId()), "Success");

        }
    });

At this point I have successfully logged in and have received an Auth token and a UserID. 至此,我已经成功登录并收到了Auth令牌和一个UserID。

My question is no where online can I find any way get extra profile information for the logged in user. 我的问题不是,在哪里可以找到任何方式在线获取已登录用户的额外个人资料信息。 I have seen some suggestions about using ServiceUser rather than MobileServiceUser but don't seem to have any luck making a ServiceUser object. 我已经看到了一些有关使用ServiceUser而不是MobileServiceUser的建议,但似乎没有运气来制作ServiceUser对象。 That can be found here. 可以在这里找到。 How to retrieve user's additional information from Azure Mobile/App Services? 如何从Azure移动/应用服务检索用户的其他信息?

Does anyone know of a solution? 有人知道解决方案吗?

Thanks in advance! 提前致谢!

If you are using Easy Authentication as described here , then you can simple append the endpoint /.auth/me to the URL. 如果您按照此处所述使用“简单身份验证”,则可以将端点/.auth/me简单地附加到URL。 For example: 例如:

Login Endpoint : https://easyauthkaushal.azurewebsites.net/.auth/login/google 登录端点https : //easyauthkaushal.azurewebsites.net/.auth/login/google

User Details : https://easyauthkaushal.azurewebsites.net/.auth/me 用户详细信息https : //easyauthkaushal.azurewebsites.net/.auth/me

Also refer to Google documentation on working with claims and scopes. 另请参阅有关使用声明和范围的Google文档。 See this: OAuth 2.0 Scopes for Google APIs 请参阅: Google API的OAuth 2.0范围

The only way to get user information besides the auth token and the User Id your service assigned the user is to go the client directed OAuth route. 除了身份验证令牌和服务分配给用户的用户ID之外,获取用户信息的唯一方法是采用客户端定向的OAuth路由。 Here is the MSDN article about it. 是有关它的MSDN文章。 Basically, you need to make the OAuth call yourself to Google, they will give you access to everything your app is authorized to have, including name, and you need to pass the token you get from them to your mobile/app service. 基本上,您需要使OAuth自己打给Google,它们将使您可以访问您的应用有权拥有的所有内容,包括名称,并且您需要将从它们获得的令牌传递给您的移动/应用服务。

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

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