Azure Google身份验证获取用户个人资料信息

问题描述 投票:1回答:1

我使用Azure移动服务来存储我的Android应用程序中的数据。用户必须使用Google登录,我使用Azure的Easy Auth来实现它。

但是,我还需要用户的显示名称和电子邮件。我搜索了很多,找不到如何获取信息的方法。我知道对于Facebook或Microsoft等其他提供商,您只需检查应包含在响应中的属性(例如Microsoft as provider),但对于Google,Azure不提供任何属性。

android azure authentication oauth google-api
1个回答
2
投票

我只是按照How to configure your App Service application to use Google login为Google登录配置我的App Service Authentication(Easy Auth)。我只是利用Server-managed authentication并通过浏览器登录我的移动应用程序后端,如下所示:

GET https://<your-app-name>.azurewebsites.net/.auth/login/google

使用fiddler捕获网络跟踪如下:

enter image description here

然后,通过浏览器访问/.auth/me端点,我可以检索用户电子邮件,如下所示:

enter image description here

此外,你可以关注Obtaining user profile information。此外,您可以访问https://www.googleapis.com/oauth2/v1/userinfo?access_token=<access_token>手动检索用户配置文件。

此外,如果您想修改google OAuth Scopes(通过googleOAuthScopes设置https://resources.azure.com数组属性)或检索刷新令牌(access_type = offline),您可以遵循此类似的issue。您可以关注App Service Token Store以获取有关App Service Authentication的更多详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.