Google Photos API - new version?
Asked Answered
F

1

8

I'm writing a program to backup my Google Photos library locally, and last week the code was working fine but in the last few days I've been repeatedly getting an error back from the API client saying that "photoslibrary v1" does not exist within Google's API library. The docs haven't changed at all - is there a problem on Google's end or is it me?

from googleapiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools

class Photos:
def __init__(self):
    self.SCOPE = "https://www.googleapis.com/auth/photoslibrary"
    self.CLIENT_SECRET = "client_id.json"
    self.store = file.Storage("storage.json")
    self.credentials = self.store.get()
    if not self.credentials or self.credentials.invalid:
        self.flow = client.flow_from_clientsecrets("client_id.json", self.SCOPE)
        self.credentials = tools.run_flow(self.flow, self.store)
    self.PHOTOS = discovery.build("photoslibrary", "v1", http=self.credentials.authorize(Http()))

photos = Photos()

googleapiclient.errors.UnknownApiNameOrVersion: name: photoslibrary  version: v1
Fairleigh answered 18/3, 2021 at 11:12 Comment(0)
P
24

Try adding the parameter static_discovery=False

self.PHOTOS = discovery.build("photoslibrary", "v1", http=self.credentials.authorize(Http()),static_discovery=False)
Push answered 14/4, 2021 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.