Python Okta SDK example not working

I am trying to set up Okta on Python 3.9 - GitHub - okta/okta-sdk-python

so, I did the following steps:

  • pip3.9 install okta
    -create token on the dev

Put the token & org on the matching fields on the following script:
import asyncio

from okta.client import Client as OktaClient

Instantiating with a Python dictionary in the constructor

config = {
‘orgUrl’: ‘https://{yourOktaDomain}’,
‘token’: ‘YOUR_API_TOKEN’
okta_client = OktaClient(config)

example of usage, list all users and print their first name and last name

async def main():
users, resp, err = await okta_client.list_users()
for user in users:
print(user.profile.first_name, user.profile.last_name)

loop = asyncio.get_event_loop()


Tried to run it and got the following exception:

Traceback (most recent call last):
File “/Users/avilevi/PycharmProjects/carbon-api/”, line 20, in
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/”, line 44, in run
return loop.run_until_complete(main)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/”, line 642, in run_until_complete
return future.result()
File “/Users/avilevi/PycharmProjects/carbon-api/”, line 13, in main
users, resp, err = await client.list_users()
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/okta/resource_clients/”, line 101, in list_users
response, error = await self._request_executor
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/okta/”, line 138, in execute
_, response, response_body, error = await self.fire_request(request)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/okta/”, line 175, in fire_request
_, res_details, resp_body, error = await
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/okta/”, line 223, in fire_request_helper
check_429 = self.is_too_many_requests(res_details.status, resp_body)
AttributeError: ‘NoneType’ object has no attribute ‘status’

Tried other functions but get the same error, I also tried to create another token, same error.
Would be happy to get some help :smile:

Hey, I digged dipper and the solution was to add a certificate locally. python - certificate verify failed: unable to get local issuer certificate - Stack Overflow You can close it, but maybe you should it to the SDK so other people will figure out how to solve it. thx

1 Like