【问题标题】:Getting user info in google drive sdk在 google drive sdk 中获取用户信息
【发布时间】:2013-11-22 07:01:49
【问题描述】:

我正在使用这三个范围:

            scopes[0] = "https://www.googleapis.com/auth/drive";
            scopes[1] = "https://www.googleapis.com/auth/userinfo.email";
            scopes[2] = "https://www.googleapis.com/auth/userinfo.profile";

授权他们,然后尝试根据:
https://developers.google.com/drive/v2/reference/permissions/list
获取用户的电子邮件地址 通过这样做:

            PermissionList permissions = _service.Permissions.List("root").Fetch();
            IList<Permission> a = permissions.Items;

我没有看到电子邮件地址。
当我在“试试看!”中包含相同的范围(甚至只有前两个)时部分,
我得到一个包含 emailAddress 的结果

我错过了什么?

【问题讨论】:

    标签: email oauth permissions google-drive-api scopes


    【解决方案1】:

    如果您正在查找授权用户的电子邮件,请尝试使用 tokeninfo 端点(出于安全目的,您无论如何都应该调用该端点)。见https://developers.google.com/accounts/docs/OAuth2Login#obtaininguserprofileinformation

    【讨论】:

      【解决方案2】:

      我可能是错的,但只是您引用范围的方式,例如scopes[0], scopes[1], scopes[2]。看起来您将它们存储在一个数组中。

      当我使用客户端 (javascript) oauth 检索用户信息时,它们只是以空格分隔。

      【讨论】:

        【解决方案3】:
        "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
        

        要添加多个范围,请在范围之间添加一个空格。

        【讨论】:

          猜你喜欢
          • 2014-03-31
          • 1970-01-01
          • 2015-04-15
          • 1970-01-01
          • 1970-01-01
          • 2015-04-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多