Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.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 尝试使用GoogleAPIv3:ERROR捕获我的所有contac_Javascript_Google Api_Google Contacts Api - Fatal编程技术网

Javascript 尝试使用GoogleAPIv3:ERROR捕获我的所有contac

Javascript 尝试使用GoogleAPIv3:ERROR捕获我的所有contac,javascript,google-api,google-contacts-api,Javascript,Google Api,Google Contacts Api,我需要帮助。我试图从Google Api V3、Auth2捕获所有CONTAC,但它返回以下错误: GET https://www.google.com/m8/feeds/contacts/default/full?callback=jQuery171029…+gsession&issued_at=1379496709&expires_at=1379500309&_aa=0&_=1379496719602 401 (Token invalid - AuthSub

我需要帮助。我试图从Google Api V3、Auth2捕获所有CONTAC,但它返回以下错误:

GET https://www.google.com/m8/feeds/contacts/default/full?callback=jQuery171029…+gsession&issued_at=1379496709&expires_at=1379500309&_aa=0&_=1379496719602 401
(Token invalid - AuthSub token has wrong scope)
首先我登录Google+,然后我尝试在Google Contacts中进行授权:

function myContacts() {
    var config = {
        'client_id': clientId,
        'scope': 'https://www.google.com/m8/feeds',
    };

    gapi.auth.authorize(config, function () {
        var authParams = gapi.auth.getToken(); // from Google oAuth
        $.ajax({
            url: 'https://www.google.com/m8/feeds/contacts/default/full',
            dataType: 'jsonp',
            type: "GET",
            data: authParams,
            success: function (data) {
                alert("success: " + JSON.stringify(data))
            },
            error: function (data) {
                console.log("error: " + JSON.stringify(data))
            }
        })
    });
}
这是正确的方法吗


谢谢您

将access\u令牌作为请求参数附加到url中,并使用授权后获取的令牌,而不是将其发送到数据。

由于goolge.com的CORS限制,您无法执行hxr(ajax)请求

不过,您可以使用此库来实现这一点。它解决了Oauth登录/从gmail检索联系人的问题)


您是否尝试添加
authParams.alt='json'在联系人呼叫之前?