我正在开发一个从Google Picasa获取相册和图片的网络应用程序.
我一直收到204,没有来自服务器的内容响应.
另外,我收到错误:请求的资源上没有'Access-Control-Allow-Origin'标头.
我在开发人员控制台中获得了javascript起源的正确凭据,但我仍然收到此错误.我已经尝试了很多方法来制作请求,但都没有成功.
我已经使用tokeninfo端点验证了访问令牌,所以我相信我正在做出正确的请求类型.
这是我要求的要求:
$.ajax({ //gives 204 no content response
url: "https://picasaweb.google.com/data/feed/api/user/default", //use default to get current logged in user
type: "GET",
beforeSend: function(xhr){ //headers
xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
xhr.setRequestHeader('GData-Version', '2');
},
dataType: "json",
success: function(){
console.log("success");
},
fail: function(){
console.log("fail");
}
})
.done(function(data){
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
此外,进行未经身份验证的请求:
$.ajax({
url: "https://picasaweb.google.com/data/feed/api/user/default", //use default to get current logged in user
type: "GET",
dataType: "json",
beforeSend: function(xhr){
xhr.setRequestHeader('GData-Version', 2);
},
success: function(){
console.log("success");
},
fail: function(){
console.log("fail");
}
}) …Run Code Online (Sandbox Code Playgroud)