1

我能够从库中获取请求令牌验证器(http://oauth.googlecode.com/svn/code/javascript/),但被困在获取访问令牌中......有人可以告诉我我在做什么错了吗?

 function goForAccessRequest1(verifier){

    var url2 = "http://www.google.com/accounts/OAuthGetAccessToken";

    var accessor2 = {
        token: OAuthToken,
        //tokenSecret: OAuthTokenSecret,
        signatureMethod : "HMAC-SHA1",
        consumerKey : "1010722015153-i8tisqmaqch26b0muqvefbfp3h18m862.apps.googleusercontent.com",
        //consumerSecret: "zZp8BsyfIzHJox1rBi8Lq3fm",
    };

    var message2 = {
        action: url2,
        method: "POST",
        parameters: {
            oauth_verifier : verifier,
            //scope : "http://www.google.com/calendar/feeds",
        }
    };

    OAuth.completeRequest(message2, accessor2);

    var requestBody = OAuth.formEncode(message2.parameters);

    //url2 = url2 + '?' + OAuth.formEncode(message2.parameters);

    var AccessTokenRequest = new XMLHttpRequest();
    AccessTokenRequest.open("POST", url2, true);

    AccessTokenRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    AccessTokenRequest.setRequestHeader("Authorization", "OAuth");

    AccessTokenRequest.send(requestBody);

    AccessTokenRequest.onreadystatechange = function receiveAccessToken(){
        if(AccessTokenRequest.readyState == 4){
            console.log(AccessTokenRequest.responseText)
        }
    }
}

每当我尝试使用“GET”发送参数时,我都会收到类似签名错误的错误,而当我在 POST 正文中发送参数时,会收到“缺少参数”的错误

4

0 回答 0