Google云端硬盘API列表文件夹获取

时间:2016-08-02 21:11:35

标签: python get google-drive-api python-requests urllib

我正在尝试查询Google云端硬盘以查找其网址。这是我的代码。我唯一改变的是我的API密钥被AAAAAAAAAA取代

    queryString = urllib.quote_plus("title = \'" + filename + "\'")
    parameters = {'key':'{AAAAAAAAAA}', 'q': queryString}
    inserted_file = requests.get('https://www.googleapis.com/drive/v2/files', params = parameters)
    print (inserted_file.url)
    print inserted_file

当我打印inserted_file时,它返回错误400.我做错了什么?

1 个答案:

答案 0 :(得分:0)

400 error响应表示提供的value无效或提供的字段组合无效。它的用户错误。这可能意味着尚未提供必填字段或参数。

它可能会为您提供API key not validBad request消息/

"message": "API key not valid. Please pass a valid API key."

"message": "Bad Request"

建议生成/使用有效凭据。有一个文档如何获取凭据/步骤来运行示例项目:https://developers.google.com/drive/v3/web/quickstart/python#top_of_page