【问题标题】:Google Photos API - new version?Google Photos API - 新版本?
【发布时间】:2021-06-15 18:51:47
【问题描述】:

我正在编写一个程序来在本地备份我的 Google 照片库,上周代码运行良好,但在过去几天里,我反复收到来自 API 客户端的错误消息,说“photoslibrary v1”在 Google 的 API 库中不存在。文档根本没有改变 - 是 Google 的问题还是我的问题?

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

【问题讨论】:

    标签: python python-3.x oauth-2.0 google-photos google-photos-api


    【解决方案1】:

    尝试添加参数static_discovery=False

    self.PHOTOS = discovery.build("photoslibrary", "v1", http=self.credentials.authorize(Http()),static_discovery=False)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-22
      • 2019-01-27
      • 1970-01-01
      • 2021-03-18
      • 2015-08-21
      • 1970-01-01
      • 2019-03-15
      • 2019-05-16
      相关资源
      最近更新 更多