如何从Google Plus OAuth获取用户电子邮件 [英] How to get user email from google plus oauth
问题描述
链接: https://sites.google.com/site/oauthgoog/Home/emaildisplayscope
在上面的链接中,我添加了电子邮件范围
From the link above I add the email scope
https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/userinfo.email
但我不理解以下内容
一旦有了有效的OAuth令牌,就可以使用它对电子邮件显示API端点进行API调用: https://www.googleapis.com/userinfo/email 如果令牌无效,将返回401错误.如果令牌有效,则将返回用户的电子邮件地址.该API还将返回一个布尔值,以指示Google是否已验证用户拥有该电子邮件地址.但是,大多数已安装的应用程序都会忽略该值.
Once you have a valid OAuth token, you can use it to make API calls to the Email Display API endpoint: https://www.googleapis.com/userinfo/email If the token is not valid, a 401 error will be returned. If the token is valid, then the user's Email address will be returned. The API will also return a boolean value to indicate whether Google has verified that the user owns that Email address. However most installed applications will ignore that value.
如何调用Email Display API端点?使用 https://www.googleapis.com/userinfo/email
How to make a call to the Email Display API endpoint? Using https://www.googleapis.com/userinfo/email
推荐答案
将范围设置为:
- https://www.googleapis.com/auth/userinfo.email and
- https://www.googleapis.com/auth/userinfo.profile
并使用端点:
https://www.googleapis.com/oauth2/v1/userinfo? alt = json
用法:
get https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=youraccess_token
您将获得JSON:
{ "id": "xx",
"name": "xx",
"given_name": "xx",
"family_name": "xx",
"link": "xx",
"picture": "xx",
"gender": "xx",
"locale": "xx"
}
这篇关于如何从Google Plus OAuth获取用户电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!