Justin Oroz
Justin Oroz

Reputation: 659

How can I send Authlib requests through a proxy?

With requests I can make a request through a proxy:

import requests
proxies = {
    "http": "http://proxy.yourorg.com:80",
    "https": "http://proxy.yourorg.com:80"
}
url = 'http://myorg.com/example'
response = requests.post(url, proxies=proxies)

Does Authlib provide a mechanism to use proxies for requests?

token = oauth.discord.authorize_access_token()
resp = oauth.discord.get('/users/@me')

Upvotes: 0

Views: 580

Answers (1)

lepture
lepture

Reputation: 2422

Since Authlib is using requests, while requests support proxy through HTTP_PROXY environment variables, you can set:

export HTTP_PROXY="http://proxy.yourorg.com:80"
export HTTPS_PROXY="http://proxy.yourorg.com:80"

While Authlib also support passing proxies into the parameters, try:

token = oauth.discord.authorize_access_token(proxies=proxies)

Upvotes: 1

Related Questions