我使用带有Python的Google Drive API收到错误403。 我可以看到谷歌驱动器上的文件,但当我尝试下载它时,我收到以下错误:
"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 我不知道自己做错了什么。
答案 0 :(得分:0)
"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."
表示您尝试访问Google API而未先进行身份验证。凭据未正确应用于您的服务。它应该弹出并要求您允许访问您的数据。