Javascript 如何在成功登录谷歌后获取电子邮件和个人资料信息
我已使用以下范围成功验证到google:Javascript 如何在成功登录谷歌后获取电子邮件和个人资料信息,javascript,api,email,google-api,google-plus,Javascript,Api,Email,Google Api,Google Plus,我已使用以下范围成功验证到google: var scopes=['email','profile','https://www.googleapis.com/auth/drive']; 我使用此选项尝试阅读用户的电子邮件和个人资料: function getEmail(resp) { var email,isFound=false; console.log(resp); for(var i=0;i<resp.emails.length && !isFound
var scopes=['email','profile','https://www.googleapis.com/auth/drive'];
我使用此选项尝试阅读用户的电子邮件和个人资料:
function getEmail(resp)
{
var email,isFound=false;
console.log(resp);
for(var i=0;i<resp.emails.length && !isFound;i++)
{
if(resp.emails[i].type==='account')
{
email=resp.emails[i].value;
isFound=true
}
}
return email;
}
function getProfile(resp)
{
console.log(resp);
console.log("Retrieved profile for "+resp.displayName);
}
function handleResponse(resp)
{
var email=getEmail(resp);
var profile=getProfile(resp);
}
我得到的不是用户的电子邮件和个人资料,而是以下回复:
{
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project.",
"data": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
],
"error": {
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project.",
"data": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
]
}
}
我打开了Google API控制台中的Google+API
,以获取以下信息:
{
"code": 404,
"message": "Not Found",
"data": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"error": {
"code": 404,
"message": "Not Found",
"data": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
]
}
}
userid
参数区分大小写,应改为userid
我测试并使用userid
会导致404错误消息,而userid
对我有效。在这种情况下,这不是一条非常有用的错误消息…可能重复:@Sid我正在使用referers设置中允许的任何referer。该问题包含其他解决方案。你试过了吗?@Sid我试过将Google+API和Contacts API激活为noavail@Sid我使用了一个不同的API密钥,它对我有效。@Scarygemi我收到一个403请求我访问未配置。请使用Google Developers Console为您的项目激活API。
我有驱动器API
,Google+API
和联系人API
处于活动状态,我这里缺少什么
{
"code": 404,
"message": "Not Found",
"data": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"error": {
"code": 404,
"message": "Not Found",
"data": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
]
}
}