OAuth - 我可以通过用户 ID 获取 Google 用户照片吗?
OAuth - Can I get Google user photo via user id?
在Facebook中,我可以通过用户id获取用户照片,像这样:
var info = await AuthenticationManager.GetExternalLoginInfoAsync();
string pictureUrl = "https://graph.facebook.com/" + info.Login.ProviderKey + "/picture?type=large";
Google可以吗?如果可能的话,你能给我 url 我可以用 ProviderKey
得到用户照片吗?
有点像:
string pictureUrl = "https://google.com/" + info.Login.ProviderKey +
"/picture?type=large";
谢谢!
不,您必须使用 https://www.googleapis.com/plus/v1/people/me
端点并传递不记名令牌,它只是在 OAuth 登录期间提供的访问令牌。
参见:https://developers.google.com/+/web/api/rest/latest/people/get
如果您使用的是较新的身份验证端点(v2/auth
和 v4/token
,如 discovery document) and request the profile
scope in your auth request, the returned ID Token will include user photo in the picture
claim, for users that have one. This question has 中所引用。
在Facebook中,我可以通过用户id获取用户照片,像这样:
var info = await AuthenticationManager.GetExternalLoginInfoAsync();
string pictureUrl = "https://graph.facebook.com/" + info.Login.ProviderKey + "/picture?type=large";
Google可以吗?如果可能的话,你能给我 url 我可以用 ProviderKey
得到用户照片吗?
有点像:
string pictureUrl = "https://google.com/" + info.Login.ProviderKey + "/picture?type=large";
谢谢!
不,您必须使用 https://www.googleapis.com/plus/v1/people/me
端点并传递不记名令牌,它只是在 OAuth 登录期间提供的访问令牌。
参见:https://developers.google.com/+/web/api/rest/latest/people/get
如果您使用的是较新的身份验证端点(v2/auth
和 v4/token
,如 discovery document) and request the profile
scope in your auth request, the returned ID Token will include user photo in the picture
claim, for users that have one. This question has