【发布时间】:2017-06-29 19:47:48
【问题描述】:
我正在尝试使用 Google Contacts API 导入用户的 gmail 联系人。这适用于我的 gmail,但当其他人尝试使用以下错误消息登录时失败:
Error: invalid_scope
This app hasn't been verified to access: {invalid = [https://www.googleapis.com/auth/contacts]} Please contact the developer for assistance. Are you the developer? If this project needs these scopes, sign in to an account with access to edit your project and try again. If not, contact the developer for help.
因为这个消息,我做了一些研究,发现这个question 表明这个应用程序需要审查。然后我为verification 提交了我的应用程序。但是,我收到一封电子邮件,说我的应用不需要谷歌的验证。
Thank you for submitting the developer verification form. Based on the information you provided, you have access to the scopes that you are planning to use. If you add any more scopes in the future, you may have to go through verification.
我请求的范围是https://www.google.com/m8/feeds/。
此范围是否需要 google 的批准?
我正在使用 gapi 库,下面是我的代码:
function start() {
var auth_obj = {
clientId: currentUser.GOOGLE_APP_ID,
scope: 'https://www.google.com/m8/feeds/'
}
gapi.client.init(auth_obj).then(function() {
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
})
};
gapi.load('client:auth2', start);
function getContacts() {
var access_token = gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().access_token
var url = "https://www.google.com/m8/feeds/contacts/default/"
url += "thin?alt=json&access_token=" + access_token
url += "&max-results=500&v=3.0"
$.get(url)
}
【问题讨论】:
-
您使用的是哪个库?还是您只是在执行手动 HTTP 请求?如果是后者,你有一些代码可以分享吗?此外,您是正确的,联系人 API 不需要批准即可使用。只需批准即可提高每天 2000 万次查询的默认限制。
-
@BlakeO'Hare 更新了代码。我正在使用 gapi 库
-
你能检查授权令牌的值吗? (虽然不要在这里粘贴)。确保它以“ya29 ...”或类似的东西开头。错误是来自 OAuth 端点还是来自联系人 API 端点?
-
不一致的错误信息可能是因为您是 [Risky Access Permissions By Unreviewed Apps](groups.google.com/forum/#!forum/risky-access-by-unreviewed-apps ] 组的成员。登录您的 Google 帐户并访问该组以查看您是否是成员。此组的成员身份将禁用 Google 的安全检查,以便您可以在发布之前开发/测试您的集成。
标签: google-oauth google-contacts-api