okta / okta-sdk-python

Apache License 2.0
234 stars 143 forks source link

Request Timeout cannot be set via an environment variable #391

Open cmc333333 opened 6 months ago

cmc333333 commented 6 months ago

I have the following environment variables set:

OKTA_CLIENT_SCOPES=okta.logs.read
OKTA_CLIENT_AUTHORIZATIONMODE=PrivateKey
OKTA_CLIENT_RATELIMIT_MAXRETRIES=4
OKTA_CLIENT_REQUESTTIMEOUT=300
OKTA_CLIENT_PRIVATEKEY=[snip]
OKTA_CLIENT_CLIENTID=[snip]
OKTA_CLIENT_CONNECTIONTIMEOUT=30
OKTA_CLIENT_ORGURL=[snip]

and the following Python script:

import asyncio

from okta.client import Client

async def main():
    client = Client({"raiseException": True})

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Unfortunately, when I run this script, an exception is raised:

/usr/src/app/main.py:11: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()
Traceback (most recent call last):
  File "/usr/src/app/main.py", line 12, in <module>
    loop.run_until_complete(main())
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/src/app/main.py", line 7, in main
    client = Client({"raiseException": True})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/okta/client.py", line 147, in __init__
    user_config.get("requestExecutor", RequestExecutor)(
  File "/usr/local/lib/python3.12/site-packages/okta/request_executor.py", line 35, in __init__
    if self._request_timeout < 0:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'str' and 'int'

Looks like the env vars aren't converted to ints (at least in this case)?