【问题标题】:Azure Google authentification get user profile infoAzure Google 身份验证获取用户个人资料信息
【发布时间】:2018-09-03 18:19:30
【问题描述】:

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

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

【问题讨论】:

    标签: android azure authentication oauth google-api


    【解决方案1】:

    我刚刚关注How to configure your App Service application to use Google login 配置我的应用服务身份验证(简易身份验证)以进行 Google 登录。我只是利用Server-managed authentication 并通过浏览器使用我的移动应用后端登录,如下所示:

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

    使用fiddler捕获网络轨迹如下:

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

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

    此外,如果您想修改 google OAuth 范围(通过 https://resources.azure.com 设置 googleOAuthScopes 数组属性)或检索刷新令牌(access_type=offline),您可以遵循类似的issue。您可以关注App Service Token Store 了解有关应用服务身份验证的更多详细信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-09
      • 2017-10-10
      • 2018-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多