gpt4 book ai didi

python - 如何通过 API key 登录 Google 云端硬盘

转载 作者:行者123 更新时间:2023-12-05 04:18:27 26 4
gpt4 key购买 nike

我按照 documentation 中的说明进行操作:

#google key
API_key = "xxxxx"
#creating an instance of the class
drive_service = build('drive', 'v2', developerKey = API_key)
#get a list of child folder in
children = drive_service.children().list(folderId='yyyyyyy', **param).execute()

一个错误:

An error occurred: https://www.googleapis.com/drive/v2/files/yyyyyyy/children?alt=json&key=xxxxx returned "Login Required">

我做错了什么?

最佳答案

这是一个极简版本,演示了使用 GDrive API V3 进行文件夹询问。

import httplib2
import pprint
import sys
from apiclient.discovery import build

def printChildren(parent):
param = {"q": "'" + parent + "' in parents and mimeType != 'application/vnd.google-apps.folder'"}
result = service.files().list(**param).execute()
files = result.get('files')

for afile in files:
print('File {}'.format(afile.get('name')))

API_KEY = 'XXXXXXX' # get from API->Credentials page in console.cloud.googl.com
FOLDER_ID = '1bWJ18tyq1h-ABQT79SgTsJQFRCIIblHS' # NOTE: folder must be publicly visible when using an API key.
service = build('drive', 'v3', developerKey=API_KEY)
printChildren(FOLDER_ID)

关于python - 如何通过 API key 登录 Google 云端硬盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14281842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com