Google Photos - API

Using Google Photos got a little bit more difficult. To connect to the Google Photos API you need to create a new project in the Google Developer console.

[Warning]Warning

For the free version there is a limit of 30 visible photos per album in the front end. Event Gallery Extended allows to show more than 30 photos per album.

[Warning]Warning

Google has deprecated the usage of the Google Photos API in a way that this is no longer practical to use with Event Gallery. Check https://www.svenbluege.de/blog/updates/217-oops-they-did-it-again-changes-to-the-google-photos-api-integration for details.

[Tip]Tip

Instead of creating the API and all the tiny things, try Google Photos - Shared Page. There you only need a simple shared URL. Details you can find here: Google Photos - Shared Page. You can also select the files from Google Photos while uploading new files and store them on your webspace

Video - Setup Google Photos

English version: https://youtu.be/A5yj2sDvENU

default

German version: https://youtu.be/iFtdT1xLdMI

default
Steps to create the Google API Project

Please check the videos above for the whole process. In summary, you need to go through those steps:

  1. Open the Google Developer Console (Google Developer Console) and sign in.
  2. Click the project selector in the top toolbar and create a new project
  3. Enable the Photos Library API and the Google Photos Picker API. Click the Enable APIs and Services button, search for the Photos Library API, click the tile and hit the Enable button. Do the same for the Google Photos Picker API.
  4. Configure the consent screen: select external user type and create the screen. Add the app name and your domains. No need to select any scopes, but please add the email address of the user with the Google Photos albums. We will not validate this app, but you need to put it to production mode. The validation is unnecessary, but it restricts the number of potential users. This does not matter, since you are the only user of this app. Everything else is handled in Event Gallery. Check the review page and go back to the dashboard.
  5. Now we need to create the credentials. Click the create credentials button and select OAuth client ID.
  6. The type needs to be web application. Add a name for the credentials. Now add the Authorized JavaScript origins. Add as many URLs as you need. Start with your main domain and add something like https://www.svenbluege.de or https://svenbluege.de. Please note, that www.foo.com and foo.com are different origins! Then add your local test URLs as well. This can be something like https://localhost or https://eg.io. If you don’t do this, you can’t use those credentials on your local test environment!
  7. Now we have the credentials and need to add them in the Event Gallery configuration
  8. Use the refresh token-button. Before you start, the program will tell you the redirect URL. Please add this to your OAuth 2.0-Client credentials. If you don’t do this, you’ll see a redirect_uri_mismatch error message.
Manage Event/Album
  1. On the Event edit page, you need to select the folder type Google Photos. An account selection drop-down and an album selector button will appear. Select the Google Photos Account you want to use and click it to see your Google Photos albums.

    Figure 3.34. Select Google Photos Folder Type

    google photos manage event 1

  2. A list of albums for the selected Google Photos Account will appear. Now select one of the albums.

    Figure 3.35. Select Album

    google photos manage event 2

  3. Don’t forget to publish this event and hit the save button and you’re done.

    Figure 3.36. Select Album

    google photos manage event 3

Limitations

By default, the Google Photos API is limited to 10.000 requests per day. That might sound much, but it is not. Since every image URL in the response is valid for 60 minutes or less, Event Gallery needs to request album data multiple times per hour. Let us assume every 10 minutes. With ongoing traffic for 24 hours on your site, this is 144 requests per day. With 50 albums we’re already at 7.200. So keep an eye on the API usage. If you reach the limit, no images will appear until the next day.

There is also a limit of 75.00 requests to images. Once this limit is reached, people will no longer see any image on your site until the next day. Never use Google Photos for a high-traffic site!

Details to the API limitations you can find here: https://developers.google.com/photos/library/guides/api-limits-quotas?hl=en

I noted that you can verify your project by Google. If I briefly read through the API policy, I see, that you should not create a clone of Google Photos. Well, it depends on how one thinks about your site, but getting the verification might get tricky. If you have other experiences, please let me know.

The image URLs Google delivers are only valid for 60 minutes. The number of API requests is limited. For every shared or sold image, a separate request is necessary to get the latest image URL. This might trigger the API limits.

Figure 3.37. Monitor your project

google photos api monitoring

All prices include VAT. The gross price will vary depending on the selected shipping country.