Javascript 谷歌联系人Api来源不匹配
我使用了谷歌ApI v3。我想获取用户的联系人列表 代码是Javascript 谷歌联系人Api来源不匹配,javascript,oauth,google-api,gmail,Javascript,Oauth,Google Api,Gmail,我使用了谷歌ApI v3。我想获取用户的联系人列表 代码是 var clientId = 'XXX'; var apiKey = 'XXX'; var scopes = 'https://www.googleapis.com/auth/contacts.readonly'; $(document).on("click", ".js-google_contacts", function() { gapi.client.set
var clientId = 'XXX';
var apiKey = 'XXX';
var scopes = 'https://www.googleapis.com/auth/contacts.readonly';
$(document).on("click", ".js-google_contacts", function() {
gapi.client.setApiKey(apiKey);
window.setTimeout(checkAuth, 3);
});
function checkAuth() {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
}
function handleAuthResult(authResult) {
//handler
}
}
我在本地主机上工作,我已经配置了Oauth
AUTHORIZED JAVASCRIPT ORIGINS : **http://localhost:80**
AUTHORIZED REDIRECT URI : **http://localhost:80/oauth2callback**
但结果是
400. That’s an error.
Error: origin_mismatch
origin=http://127.0.0.1
redirect_uri=postmessage
scope=https://www.googleapis.com/auth/contacts.readonly
response_type=token
immediate=false
include_granted_scopes=true
authuser=0
有人能帮我吗?遇到了同样的问题。我使用了不同的源URL,删除和添加了端口,但似乎在google基础设施上传播设置实际上需要一段时间。origin“可能”(我自己没有检查)是字符串比较。所以可能不等于