-
Notifications
You must be signed in to change notification settings - Fork 272
Can we use proxy to access google drive ? #109
Comments
@karamjaber this is indeed possible. Each connection is made with an Your code will look something like the following: from pydrive.drive import GoogleDrive
import httplib2
from httplib2 import socks
# Create proxied http object (taken from StackOverflow answer).
http = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP,
<proxy host address>, 8080,
proxy_user = <proxy user id>,
proxy_pass = <proxy password>))
# Setup drive.
drive = GoogleDrive(gauth)
# Setup file object.
file1 = drive.CreateFile({'title': 'Hello.txt'}) # Create GoogleDriveFile instance with title 'Hello.txt'.
file1.SetContentString('Hello World!') # Set content of the file from given string.
# Upload file using the proxied http connection.
file1.Upload(param={"http": http}) Note: The above code is not tested. If the above doesn't work as expected 1) make sure the proxy connection works using something like |
Is there any other way that doesn't use httplib2 ? because socks is alwayes None... and when i change it to the number 3 it doesn't work.... |
No, it is not possible to use another library, unfortunately. PyDrive would need to be rewritten to replace the It sounds like you have some problems with your imported packages. Substituting For future reference, you usually include 4 things in a bug or issue report: 1) Summary, 2) steps to reproduce, 3) expected result, and 4) actual results. That way it's easier to find out what you are talking about and be able to help you better :) |
It seems like that defining a proxy with httplib2 is not working, the code that i run is :
The expected behaviour is that after this code had run , a file with the name Hello.txt and content Hello word will be uploaded to google drive but the above code just prints 9 and then opens the browser for authentication.
|
Thank you for sending all of this info, and I'm sorry to hear that it is still not working. Could you try whether you can request any website at all (rather than trying to use your http object in PyDrive)? e.g. if you insert this line after you create the http object, can you tell me what it prints? resp, content = http.request("http://google.com", "GET")
print(resp)
print(content) |
No.
|
Hmm. It looks like there is a problem with your proxy setup (or connection code). Since this is not technically related to this library and since I don't have expertise in setting up python proxies, you may be best off trying to post this question on StackOverflow or the |
How to Login Auth Through SOCK proxy? |
Read this PR: #198 and it work now # -*- coding: utf-8 -*-
import httplib2
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
proxy_info = httplib2.ProxyInfo(proxy_type=httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL,
proxy_host='localhost',
proxy_port=1080)
gauth.http = httplib2.Http(proxy_info=proxy_info)
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
if __name__ == '__main__':
print(drive) |
The authentication is working, but how can I use proxy in drive.ListFile GetList() and drive.CreateFile Upload() functions? |
I want to use the pydrive with proxy.
Is it supported by pyDrive ?
The below example doesn't work because i need a proxy connection with googleAuth:
The text was updated successfully, but these errors were encountered: