$.ajax({
beforeSend: function (request)
{
request.setRequestHeader('Authorization', 'Bearer '+ TOKEN);
//request.setRequestHeader('Authorization', TOKEN);
//request.setRequestHeader('X-JavaScript-User-Agent', 'Google APIs Explorer');
},
url: 'https://www.googleapis.com/plus/v1/people/me/people/visible?key='+ API_KEY,
//url: 'https://www.googleapis.com/plus/v1/people/me/people/visible',
//url: 'https://www.googleapis.com/plus/v1/people/'+ UID +'/people/visible',
//url: 'https://www.googleapis.com/plus/v1/people/'+ UID +'/people/visible?key='+ API_KEY,
data: null,
dataType: 'jsonp',
success: function(result){
console.log(result);
}
});
在playground是200 OK和plus.people.list偉大的工作,但是當涉及到我的代碼,我得到的是:谷歌授權的請求問題
Object {domain: "usageLimits", reason: "accessNotConfigured", message: "Access Not Configured"}
更新1: 根據到https://developers.google.com/console/help/?hl=ru#UsingKeys我需要授權的是access_token,所以我刪除了所有APP_KEYs和 根據@SLaks無法設置請求頭使用JSONP。相反,我在查詢字符串上傳遞了不記名標記,但沒有任何更改,同樣的問題。無論如何,謝謝你的幫助人。
$.ajax({
//url: 'https://www.googleapis.com/plus/v1/people/me/people/visible?access_token='+ TOKEN,
//url: 'https://www.googleapis.com/plus/v1/people/me/people/visible?access_token='+ encodeURIComponent(TOKEN),
//url: 'https://www.googleapis.com/plus/v1/people/me/people/visible?token_type=Bearer&access_token='+ TOKEN,
//url: 'https://www.googleapis.com/plus/v1/people/me/people/visible?token_type=Bearer&access_token='+ encodeURIComponent(TOKEN),
//url: 'https://www.googleapis.com/plus/v1/people/'+ UID +'/people/visible?access_token='+ TOKEN,
//url: 'https://www.googleapis.com/plus/v1/people/'+ UID +'/people/visible?access_token='+ encodeURIComponent(TOKEN),
//url: 'https://www.googleapis.com/plus/v1/people/'+ UID +'/people/visible?token_type=Bearer&access_token='+ TOKEN,
//url: 'https://www.googleapis.com/plus/v1/people/'+ UID +'/people/visible?token_type=Bearer&access_token='+ encodeURIComponent(TOKEN),
data: null,
dataType: 'jsonp',
success: function(resp){console.log(resp);}
});
修復! 經過修改google apis控制檯問題的一些變化,我覺得很笨。我所要做的只是在服務中啓用Google+ API,並在API Access中將通知端點添加到通知端點(不要以爲第二個幫助,但無論如何它現在正在工作!)。
不能爲JSONP設置請求頭。 – SLaks
您是否在雲端控制檯中啓用了JSON Api? – karthikr
@SLaks我應該如何設置它? – qpaycm