0
我收到错误403,使用Google Drive API和Python。 我可以看到谷歌驱动器上的文件,但是当我tryed下载它,我得到了以下错误:错误403使用Google Drive API和Python - 每日限制未经验证的使用超出
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
我正在使用的代码:
try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Drive API Quickstart'
def get_credentials():
home_dir = os.path.expanduser('~')
credential_dir = os.path.join(home_dir, '.credentials')
if not os.path.exists(credential_dir):
os.makedirs(credential_dir)
credential_path = os.path.join(credential_dir,
'drive-python-quickstart.json')
store = Storage(credential_path)
credentials = store.get()
if not credentials or credentials.invalid:
flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
flow.user_agent = APPLICATION_NAME
if flags:
credentials = tools.run_flow(flow, store, flags)
else: # Needed only for compatibility with Python 2.6
credentials = tools.run(flow, store)
print('Storing credentials to ' + credential_path)
return credentials
def main():
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('drive', 'v3', http=http)
results = service.files().list(
q="'0BxZjsrGFMvPSNmprUFp0Y25BNFU' in parents", #first execution...
pageSize=10,
fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])
if not items:
print('No files found.')
else:
print('Files:')
for item in items:
#print('{0} ({1})'.format(item['name'], item['id']))
#file_id = '0BxZjsrGFMvPSWmtDYXB6RG5VTHM'
request = service.files().get_media(fileId='0BxZjsrGFMvPSWmtDYXB6RG5VTHM')
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
#print ("Download %d%%." % int(status.progress() * 100))
if __name__ == '__main__':
main()
我也熟悉OAuth 2.0客户端配置:https://prnt.sc/gqasjz 我不知道我在做什么错。