Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌联系人Api来源不匹配_Javascript_Oauth_Google Api_Gmail - Fatal编程技术网

Javascript 谷歌联系人Api来源不匹配

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

我使用了谷歌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
            }
        }
我在本地主机上工作,我已经配置了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“可能”(我自己没有检查)是字符串比较。所以可能不等于