Does python client support proxy?
See original GitHub issueHello, you know the google APIs are blocked in China, so we can only access these APIs by proxy, but I don’t know whether the python client support proxy setup? If yes, please tell me how. If no, could you please add the proxy feature? Thanks!
However, I can set up a global proxy manually by this way, but it a global proxy, other requests would go through with the proxy, which is unnecessary.
import socket
from httplib2 import socks
import google_auth_oauthlib.flow
Socks5 proxy
socket.socket = socks.socksocket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 1086)
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
CLIENT_SECRETS_FILE, scopes=SCOPES)
flow.authorization_url(
# Enable offline access so that you can refresh an access token without
# re-prompting the user for permission. Recommended for web server apps.
access_type='offline',
# Enable incremental authorization. Recommended as a best practice.
include_granted_scopes='true')
Hope there is any better way to handle the issue. 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to use proxies with Python Requests Proxy Module - Zyte
Configuring and using proxies is not easy, especially when sending HTTP requests. Built-in modules like urllib, urllib2 help us deal with HTTP requests....
Read more >How do I use a proxy server with Python Requests? - ReqBin
To use a proxy server with Python requests, you can pass the proxy address to the Requests library method with the "proxies" parameter....
Read more >How to Use Pip with a Proxy Server - ActiveState
Click to install and use PIP with a Proxy server for security and privacy. Understand the alternative way to secure pip use.
Read more >PySocks - PyPI
This Python module allows you to create TCP connections through a SOCKS proxy without any special effort. It also supports relaying UDP packets...
Read more >Proxy connection with Python - Stack Overflow
You can use the HTTP_PROXY in python in order to connect to your proxy server. You can find more ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Folyd, thank you for posting your script! I use Jupyter notebook mostly, and the following snippet from your code helped a lot! For Jupyter notebooks, all interpreters for different notebooks are naturally separated from each other. Then, the solution that you are not satisfied with should work perfectly for Jupyter notebooks.
PS: more on setting things up for those who stumble into this page on Setting up the Shadowsocks Client on Windows 10 machine ==> just be careful when one first sets up the Shadowsocks client. In the same Edit Server window, one get to choose which Proxy Port to enable. To reuse the code snippet above, one need to change the Proxy Port to 1086. The default Proxy Port is 1080.
I my use case, the code snippet worked with a normal Windows 10 Shadowsocks client and Jupyter notebooks hosted on a WSL session.
I tried to use it that way, but on PFSense’s Squid Proxy it’s showing:
NONE/000 error:transaction-end-before-headers