Error trying to access "Google Drive" using python (google source code quickstart.py)

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

I followed the tutorial of the official google website: https://developers.google.com/drive/...t-python?hl=es In addition, I saw a video tutorial about this, I think I am doing the same like the guys from the video.

I will tell you the steps that I followed literally:

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

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

At this stage, everything is going well, actually for import, etc. there is no mistake.

3 - API to enable the drive: I follow the steps as is, create a "client identifier for the native application" and "client identifier for the Internet" application "

4 - I create a document "document.txt" and copy the source code as a quick launch.

5 - I replace "CLIENT_ID" and "CLIENT_SECRET", indicating in the "Client ID for the native application" (I also tested the web application)

6 - I launch, and exit to the screen:

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 this error:

 import logging ... logging.basicConfig() 

Now output:

 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 this link, the error is:

 401 - That 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=... 
+6
source share
3 answers

I found a problem, I didn’t enter the email address and client name in the "Consent" section.

Now it works well.

+1
source

In the oauthclient.util module under consideration, some assumptions are made that there is logging, and this warning actually masks the more detailed warning / error that he was trying to write to the log.

If you add some entries to your own code, then it should reveal the main error:

 import logging logging.basicConfig() 

was enough to replace the appearance of the above error with a true error in my output (YMMV).

Once this is resolved, you can probably delete these two lines safely (although you will probably come back here if something goes wrong).

This question arose in the Google search engine No handlers could be found for logger "oauth2client.util" next to this problem and this question .

+5
source

Actually adding the above code completely fixes the problem.

 import logging logging.basicConfig(filename='debug.log',level=logging.DEBUG) 
0
source

Source: https://habr.com/ru/post/975122/


All Articles