我有以下Google云平台项目的服务帐户json凭据文件:
如何使用此服务帐户向Google Drive API进行身份验证?例如,当我尝试执行以下操作时:
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
flow = client.flow_from_clientsecrets('mykey.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('drive', 'v3', http=creds.authorize(Http()))
results = service.files().list(pageSize=10, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])
我在运行
flow
命令,该命令抱怨密钥文件的格式不是以
web
或
installed
:
Invalid file format. See https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
Expected a JSON object with a single property for a "web" or "installed" application
有没有办法用上面的键列出我的Google服务帐户的驱动器文件?如果是的话,怎么办?