每个人.我尝试了不同的方法很多,这里。如何使用Drive Rest API读取Drive照片找到了解决方法.但始终没有。
SCOPES = 'https://www.googleapis.com/auth/drive.photos.readonly'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials1.json', SCOPES)
creds = tools.run_flow(flow, store)
driveService = discovery.build('drive', 'v3', http=creds.authorize(Http()))
# driveService = apiclient.discovery.build('drive', 'v3', http = httpAuth) # Выбираем работу с Google Drive и 3 версию API
print(driveService)
page_token = None
while True:
print("1")
response = driveService.files().list(q="mimeType='images/jpeg'",
spaces='photos',
fields='nextPageToken, files(id, name)',
pageToken=page_token).execute()
for file in response.get('files', []):
print(file.get('link'))
photos1.append(file.get('name'))
photos2.append(file.get('id'))
print('Found file: %s (%s)' % (file.get('name'), file.get('id')))
page_token = response.get('nextPageToken', None)
if page_token is None:
print("2")
break
给出上面的错误
更新。
response = driveService.files().list(
spaces='photos').execute()
尽管我的硬盘里有照片,但什么也没有返回。