尝试访问“Google云端硬盘”时出错用python(google quickstart.py源代码) [英] Error trying to access "google drive" with python (google quickstart.py source code)

查看:269
本文介绍了尝试访问“Google云端硬盘”时出错用python(google quickstart.py源代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图学习如何从Python访问Google Drive,但我遇到了问题。

我遵循谷歌官方网站的教程: https://developers.google.com/drive/...python?hl=es
另外,我已经看过关于这个的视频教程,我认为我的确和视频工作人员完全相同。



我告诉你我遵循的步骤:

1 - 安装pip工具从Google安装SDK。



2 - 从Google安装SDK:pip install --upgrade google-api-python 客户端



在这一步中一切顺利,实际上进行导入等操作没有任何问题。

<3> - 驱动器启用API:
我按照原样执行这些步骤,创建一个本机应用程序的客户端ID和一个web $ b的客户端ID $ b应用程序



4 - 创建文档document.txt并复制快速入门的源代码。

5 - 通过出现在本机应用程序的客户端ID中,我替换了CLIENT_ID和CLIENT_SECRET(我也使用Web应用程序进行了测试)



6 - 我运行,屏幕输出为:

 没有处理程序可以找到对于记录器oauth2client.util
转到您的浏览器的以下链接:
< link>
输入验证码:

寻找解决方案时,我发现了一些信息那个错误:

 导入记录
...
logging.basicConfig()

现在,输出为:

  C:\workspaces\asd\prsGoogleApi> quickstart.py 
警告:oauth2client.util:__init __()至多需要4个位置参数(5个
en)
转到浏览器中的以下链接:
< link>
输入验证码:

如果我尝试访问该链接,错误是:

  401  - 这是错误
错误:invalid_client。
没有应用程序名称。

请求详情:
response_type = code $ b $ scope = https://www.googleapis.com/auth/drive
access_type =离线
redirect_uri = urn:ietf:wg:oauth:2.0:oob
client_id = ...


解决方案

我发现问题,这是我没有把我的电子邮件地址和客户名称放在同意屏幕部分。

现在它运作良好。


I'm trying to learn how to access Google Drive from Python but I have problems.

I followed the tutorial of google's official website: https://developers.google.com/drive/...t-python?hl=es In addition, i have seen the video tutorial about this, I think I do the same than the video guys exactly.

I tell you the steps I've followed literally:

1 - Install pip tool to install the SDK from Google.

2 - Install the SDK from Google: "pip install --upgrade google-api-python-client"

In this step all goes well, in fact to make imports etc. there is no fault.

3 - Drive Enable API: I follow the steps as is, create a "client ID for native application" and a "client ID for web application "

4 - I create the document "document.txt" and copy the source code as it quickstart.

5 - I replace "CLIENT_ID" and "CLIENT_SECRET" by appearing in "Client id for native application" (I've also tested with web application)

6 - I run, and screen output is:

No handlers could be found for logger "oauth2client.util"
Go to the following link in your browser:
<link>
Enter verification code:

Looking for a solution, i found something to get some information about that error:

import logging
...
logging.basicConfig()

Now, the output is:

C:\workspaces\asd\prsGoogleApi>quickstart.py
WARNING:oauth2client.util:__init__() takes at most 4 positional arguments (5 giv
en)
Go to the following link in your browser:
<link>
Enter verification code:

If I try to access that link, the error is:

401 - That's an error
Error: invalid_client.
No application name.

Request details:
response_type=code
scope=https://www.googleapis.com/auth/drive
access_type=offline
redirect_uri=urn:ietf:wg:oauth:2.0:oob
client_id=...

解决方案

I have found the problem, it was that I had not put my email address and client name at "Consent screen" section.

Now it works good.

这篇关于尝试访问“Google云端硬盘”时出错用python(google quickstart.py源代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆