Testing Google Photos API via Google Apps
- Create a new shared album and return its shareable URL
- Find
Album ID
of a shared album with a specific shareable URL - Unshare a shared album with a specific
Shared Album ID
- Search media items of a specific date and render the images with a grid layout in a HTML file.
- (Work in progress) Add media items to a specific album.
- Go to your Google Drive, open a new Apps Script Project.
- Copy all .gs and html files to the project.
- Go to Google Cloud Platform, create a new project.
- Enable Google Photos API in the GCP web console.
- Create an OAuth credentials. Choose Web Application as the application type.
When prompted for the authorized redirect URL enter
https://script.google.com/macros/d/{SCRIPTID}/usercallback
and replace{SCRIPTID}
with the Script ID under the 'Project properties' of Apps Script Editor. - Add a product name to the consent screen, and Save.
- Go back to the Apps Script project, select 'Libraries...' from the Resources menu. Enter
1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF
next to 'Add a library' and click add to import the Google OAuth2 library, click Save. - Open
code.gs
in the Script Editor, replace the values of the following variables,- ClientID = ''
- ClientSecret = ''
- ApiKey = ''
- var execUrl = ''
- Deploy the project as a web application. Choose 'Me (your-username@gmail.com)' under Execute the app as, and
Only myself
orAnyone
under Who has access to the app depending on your usage. - Use the debug tool to run the
doGet()
function, and authorize for Google Services. - Open a new tab in your browser, copy the URL of your deployed app and try to execute an app function.You'll see one of the authorization dialogs shown here when it is run.
- Embed the application to a HTML page using
<iFrame>
, if you don't want to see the Google signature at the top of the web app.
- Go to https://myaccount.google.com/.
- On the left navigation panel, select Security.
- On the Third-party apps with account access panel, select Manage third-party access.
- Select the app called
Photos
/photos
. - Select Remove Access.
- Go back to the Apps Script Editor, use the debug tool to run
logout()
function in the script filecode.gs
.