googlearchive/PyDrive

argument should be integer or bytes-like object, not 'str'

kurdishdevil opened this issue · 0 comments

i'm trying to run pydrive on a remote server, but i get this error after submitting the auth code with

gauth.CommandLineAuth()

here's the entire error

Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=685978119888-2fbsd3hmbmdjf11l976t1bma0thepekl.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.google
apis.com%2Fauth%2Fdrive&access_type=offline&response_type=code
Enter verification code: 4/wwGmzGdLZlTik2zijZS4fjzAfbt-JvstslPApcT68rcnL2ObgW9EKg0
Traceback (most recent call last):
File "/home/hedihadi/aw.py", line 18, in
uploadimg("h","h","e")
File "/home/hedihadi/aw.py", line 7, in uploadimg
gauth.CommandLineAuth() # <--
File "/home/hedihadi/.local/lib/python3.7/site-packages/pydrive/auth.py", line 125, in _decorated
self.Auth(code)
File "/home/hedihadi/.local/lib/python3.7/site-packages/pydrive/auth.py", line 495, in Auth
self.Authenticate(code)
File "/home/hedihadi/.local/lib/python3.7/site-packages/pydrive/auth.py", line 508, in Authenticate
self.credentials = self.flow.step2_exchange(code)
File "/usr/lib/python3.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/lib/python3.7/site-packages/oauth2client/client.py", line 2054, in step2_exchange
http, self.token_uri, method='POST', body=body, headers=headers)
File "/usr/lib/python3.7/site-packages/oauth2client/transport.py", line 282, in request
connection_type=connection_type)
File "/usr/lib/python3.7/site-packages/httplib2/init.py", line 1957, in request
cachekey,
File "/usr/lib/python3.7/site-packages/httplib2/init.py", line 1622, in _request
conn, request_uri, method, body, headers
File "/usr/lib/python3.7/site-packages/httplib2/init.py", line 1528, in _conn_request
conn.connect()
File "/usr/lib/python3.7/site-packages/httplib2/init.py", line 1309, in connect
sock.connect((self.host, self.port))
File "/usr/lib/python3.7/site-packages/socks.py", line 406, in connect
self.__negotiatehttp(destpair[0],destpair[1])
File "/usr/lib/python3.7/site-packages/socks.py", line 357, in __negotiatehttp
while resp.find("\r\n\r\n")==-1:
TypeError: argument should be integer or bytes-like object, not 'str

this is my entire code, it works without any problems on my computer, but not on the remote machine

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

def uploadimg(kart, band, fraction):
gauth = GoogleAuth()
gauth.CommandLineAuth() # <--
drive = GoogleDrive(gauth)

file1 = drive.CreateFile({'title': "lqi"+fraction+"bandi"+band+"karti"+kart})
file1.SetContentFile("hi.jpg")
file1.Upload()

file3 = drive.CreateFile({'id': file1['id']})

uploadimg("h","h","e")