|
| 1 | +# ------------------ |
| 2 | +# Only for running this script here |
| 3 | +import asyncio |
| 4 | +import logging |
| 5 | +import sys |
| 6 | +from os.path import dirname |
| 7 | + |
| 8 | +sys.path.insert(1, f"{dirname(__file__)}/../../..") |
| 9 | +logging.basicConfig(level=logging.DEBUG) |
| 10 | +# ------------------ |
| 11 | + |
| 12 | +logger = logging.getLogger(__name__) |
| 13 | + |
| 14 | +import os |
| 15 | +from slack import WebClient |
| 16 | + |
| 17 | +# export HTTPS_PROXY=http://localhost:9000 |
| 18 | +client = WebClient(token=os.environ["SLACK_API_TOKEN"]) |
| 19 | +response = client.auth_test() |
| 20 | +logger.info(f"HTTPS_PROXY response: {response}") |
| 21 | + |
| 22 | +client = WebClient( |
| 23 | + token=os.environ["SLACK_API_TOKEN"], |
| 24 | + proxy="http://localhost:9000" |
| 25 | +) |
| 26 | +response = client.auth_test() |
| 27 | +logger.info(f"sync response: {response}") |
| 28 | + |
| 29 | +client = WebClient( |
| 30 | + token=os.environ["SLACK_API_TOKEN"], |
| 31 | + proxy="localhost:9000" |
| 32 | +) |
| 33 | +response = client.auth_test() |
| 34 | +logger.info(f"sync response: {response}") |
| 35 | + |
| 36 | +async def async_call(): |
| 37 | + client = WebClient( |
| 38 | + token=os.environ["SLACK_API_TOKEN"], |
| 39 | + proxy="http://localhost:9000", |
| 40 | + run_async=True |
| 41 | + ) |
| 42 | + response = await client.auth_test() |
| 43 | + logger.info(f"async response: {response}") |
| 44 | + |
| 45 | +asyncio.run(async_call()) |
| 46 | + |
| 47 | +# Terminal A: |
| 48 | +# pip3 install proxy.py |
| 49 | +# proxy --port 9000 --log-level d |
| 50 | + |
| 51 | +# Terminal B: |
| 52 | +# export SLACK_API_TOKEN=xoxb-*** |
| 53 | +# python3 integration_tests/samples/issues/issue_714.py |
0 commit comments