How to use the Google Photos API in a Python Script?

167 views Asked by At

When I download the contents of a Google Photos album, I lose the order of the photos. To solve this problem, I wrote a 109 line Python program that uses the Google Photos API to simply enumerate the names of the photo filenames in the order they appear in the album.

I got it to work, but to use it I have to click through three different screens warning me that my app has not be reviewed by Google. It's not clear to me how I can can get my 109 lines of Python reviewed by Google.

Does anyone know any way of streamlining this process?

The code I used for authorization is

  # The Photos Library API wants the credentials in a file.
  fd, filename = tempfile.mkstemp()
  os.write(fd, bytes("""{"installed":{
"client_id":
"1066868152635-2h94jkkktf0lb1rknlretg82jl7hq7t3.apps.googleusercontent.com",
"project_id":"photos-downloader-400903",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"client_secret":"REDACTED",
"redirect_uris":["http://localhost"]
}}
""", "utf-8"))
  os.close(fd)

  # Authorize use of the API to read photo library metadata.
  flow = InstalledAppFlow.from_client_secrets_file(filename,
    scopes=["https://www.googleapis.com/auth/photoslibrary.readonly"])
  os.remove(filename)

  flow.run_local_server(
    authorization_prompt_message=None,
    success_message="Authorization successful. You may close this window.",
  )
  session = flow.authorized_session() 
0

There are 0 answers