Make Python 3.x Slack (slackclient) Use A Corporate Proxy
I have some Python 3 code and can make it use the module slackclient to post to channels, no problem. However if I run this code from our corporate servers where all traffic needs
Solution 1:
Figured it out. I'll leave this here in case somebody else has the same problem. Looks like it's built in, just pass a proxies dict in.
def get_slackclient():
#https://api.slack.com/custom-integrations/legacy-tokens
token = "blah-blah-blah"
proxies = dict(https="proxy.evilcorp.com:8080", http="proxy.evilcorp.com:8080")
sc = SlackClient(token, proxies=proxies)
return sc
Well, that was easy :)
UPDATE
If you happen to upgrade to the latest slack module, it is a little different and only http:// proxies are supported (no secure for you!). And you pass in a str
instead of a dict
so just one proxy.
Just change to this:
proxy = "proxy.evilcorp.com:8080"sc = slack.WebClient(token, timeout=60, proxy=proxy)
You'll note that actually making the call to the api has changed as well, like this:
sc.chat_postMessage(channel=thechannel, text=thetext, username=theusername, unfurl_links="true")
Post a Comment for "Make Python 3.x Slack (slackclient) Use A Corporate Proxy"