I'm trying to send a file to a google drive with python but I'm stuck someway at the auth part.
When I run the code below, the webpage from google open correctly, I can choose my account and it gives me the congratz message : "The authentication flow has completed.".
import os
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from requests.auth import HTTPBasicAuth
#Then we authenticate to google
print("debug-2")
g_login = GoogleAuth()
print("debug-1")
g_login.LocalWebserverAuth()
print("debug0")
drive = GoogleDrive(g_login)
#And we send the file
print("debug1")
with open("test.txt","r") as file:
print("debug2")
file_drive = drive.CreateFile({'title':os.path.basename(file.name) })
file_drive.SetContentString(file.read())
file1_drive.Upload()
print("debug3")
Looks great, but in my shell the code is stuck at "debug-1", as if the "LocalWebserverAuth()" had never worked. Also, there are still no files in my drive so the upload is really not working and not just "visually stuck".
Here is the message in the shell :
And when I let it end all by itself, I get a python error : httplib.ResponseNotReady
.
Any idea is welcome !
UPDATE : Connection problem. Mine was caused by not using proxy.
The root cause of this error is likely to do with your firewall/antivirus
blocking incoming/outgoing connections. Try to disable that and see if it solves the problem.
You may also see additional solutions here