我使用了Google 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.setApiKey(apiKey);
window.setTimeout(checkAuth, 3);
});
function checkAuth() {
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
}
function handleAuthResult(authResult) {
//handler
}
}
我在localhost工作,我已经配置了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,删除和添加端口,但似乎实际上需要一段时间才能在谷歌基础设施上传播设置。