【问题标题】:OAuth - Can I get Google user photo via user id?OAuth - 我可以通过用户 ID 获取 Google 用户照片吗?
【发布时间】:2016-01-18 23:49:55
【问题描述】:

在 Facebook 中,我可以使用用户 ID 获取用户照片,如下所示:

var info = await AuthenticationManager.GetExternalLoginInfoAsync();

string pictureUrl = "https://graph.facebook.com/" + info.Login.ProviderKey + "/picture?type=large";

在谷歌有可能吗?如果可能的话,你能给我一个网址,我可以用ProviderKey获取用户照片吗?

有点像:

string pictureUrl = "https://google.com/" + info.Login.ProviderKey + "/picture?type=large";

谢谢!

【问题讨论】:

    标签: c# asp.net-mvc google-oauth


    【解决方案1】:

    不,您必须使用https://www.googleapis.com/plus/v1/people/me 端点并传递一个承载令牌,该令牌只是在 OAuth 登录期间提供的访问令牌。

    见:https://developers.google.com/+/web/api/rest/latest/people/get

    【讨论】:

      【解决方案2】:

      如果您使用较新的身份验证端点(v2/authv4/token,在 discovery document 中引用)并在您的身份验证请求中请求 profile 范围,则返回的 ID 令牌将在 @ 中包含用户照片987654326@ 声明,适用于拥有一个的用户。这个问题有more info

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-04-19
        • 1970-01-01
        • 2016-01-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多