Using proxies

WebexSimpleApi

WebexSimpleApi can be used with with proxies by passing the URL of the proxy in the proxy_url parameter when instantiating the API object:

from wxc_sdk import WebexSimpleApi

with WebexSimpleApi(access_token='your_access_token',
                    proxy_url='http://your.proxy.url:port') as api:
    # now can use the connection object for you code
    users = list(api.people.list())
...

The proxy will then be used for all HTTPS requests initiated by the API object.

If the proxy requires authentication, then the credentials can be included in the proxy_url parameter in this format:

WebexSimpleApi in addition to the optional proxy_url parameter also accepts the optional verify parameter. Both, proxy_url and verify are used to set the proxies and verify attributes of the requests.Session baseclass of the RestSession object that is used for all HTTPS requests by the api object.

For more advanced use cases the RestSession object of the api object can be accessed and updated directly.

AsWebexSimpleApi

Also the asyncio variant AsWebexSimpleApi can be used with with proxies by passing the URL of the proxy in the proxy_url parameter when instantiating the API object:

from wxc_sdk.as_api import AsWebexSimpleApi

async with As WebexSimpleApi(access_token='your_access_token',
                             proxy_url='http://your.proxy.url:port') as api:
    # now can use the connection object for you code
    users = await api.people.list()

The proxy will then be used for all HTTPS requests initiated by the API object.

If the proxy requires authentication, then the credentials can be included in the proxy_url parameter in this format:

AsWebexSimpleApi uses an AsRestSession object that is based on aiohttp.ClientSession for all requests. Proxy parameters are not directly supported by aiohttp.ClientSession but can be passed as arguments when calling the aiohttp.ClientSession.request() method. The AsRestSession constructor in addition to proxy_url also accepts the ssl parameter which is passed to each call of the aiohttp.ClientSession.request() method.

For further customization additional parameters given to the AsWebexSimpleApi constructor are passed to the AsRestSession constructor of the AsWebexSimpleApi.session attribute .