Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get List of Albums Google Picasa

I'm developing a web application that gets albums and images from Google Picasa.

I keep getting a 204, no content response from the server.

In addition, I am getting the error: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have the proper credentials in the developer console for javascript origins, and yet I still am getting this error. I have tried many ways to craft the request, but none have been successful.

I have verified the access token using the tokeninfo endpoint, so I believe I am making the right type of requests.

Here is the request I am making:

    $.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);
            });

Also, making an un-authenticated request:

                    $.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");
                }
            })
            .done(function(data){
                console.log(data);
            });
like image 623
KardJaster Avatar asked Nov 01 '22 08:11

KardJaster


1 Answers

The Picasa Web API does not support CORS for authenticated requests. You will have to make your requests from a server instead of via JavaScript.

like image 73
abraham Avatar answered Nov 13 '22 21:11

abraham