I posted this as an answer to a related question but it was deleted by a moderator, so I'm posting this now as a question. The related question is
Accessing shared albums from Google Photos
I am trying to access a Google Photos shared album using JavaScript. Public albums created with Picasa are easier to deal with using the Picasa Web Albums Data API.
I've developed a peculiar solution parsing the HTML contents of a shared album URL, such as
https://photos.google.com/share/<album>?key=<key>
The parsing function is
function getgooglephotos2(result)
{
var r2 = result.substr(result.search("AF_initDataCallback\\("));
var r3 = r2.substr(0, r2.search("https://video"));
var img = r3.search("https:");
while (img != -1) {
var r4 = r3.substr(img);
var imgend = r4.search("\"");
var r5 = r4.substr(0, imgend);
// r5 contains an image url
r3 = r4.substr(imgend);
img = r3.search("https:");
}
}
I would prefer a cleaner approach. Any idea?
Thanks.
PS: it seems that using authentication, I can reach a Google Photos shared album, but I am trying to implement a solution that doesn't require authentication for shared (public) albums. Here's a link
https://adodson.com/hello.js/demos/albums.html
A simpler approach to test this is
Authenticate on picasa and fetch your userid
https://picasaweb.google.com
After authentication you will reach
https://get.google.com/albumarchive/<userid>?source=pwa
Get your album list using the Picasa Web Albums Data API
https://picasaweb.google.com/data/feed/api/user/<userid>
I'm just developing app that doesn't require authentication. Anyway somehow you need to point out which album should be displaying. In my project I'm using Firebase to store URLs to shared albums. Then I request the URL and get photos using regex. To retrieve the photos I used this tutorial:
At the moment there is no way to access shared albums directly from Google Photos without authentication.