Coder Social home page Coder Social logo

hello world? about okta-sdk-python HOT 8 CLOSED

okta avatar okta commented on July 22, 2024
hello world?

from okta-sdk-python.

Comments (8)

bretterer avatar bretterer commented on July 22, 2024

@gabrielsroka I will add this to our list to take a look at, however, until then, here is a working example for you to take a look at.

import asyncio
from okta.client import Client as OktaClient

async def main():
    my_okta_client = OktaClient()

    usr_list, resp, err = await my_okta_client.list_users()
    print(err)
    print(f"How many users in this list? {len(usr_list)}")

asyncio.run(main())

Internal Ref: OKTA-338626

from okta-sdk-python.

bretterer avatar bretterer commented on July 22, 2024

This example shows you not passing anything into your OktaClient, so it relies on your ~/.okta/okta.yaml file for information

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on July 22, 2024

i'm using ENV variables, per the README.

i'm getting

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\okta\client.py", line 20, in <module>
    from okta.config.config_setter import ConfigSetter
ModuleNotFoundError: No module named 'okta.config'

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on July 22, 2024

i'm also getting

ModuleNotFoundError: No module named 'okta.client'

i tried it on 3 separate machines (Windows and Ubuntu). i tried uninstalling the old, beta okta package, too

from okta-sdk-python.

bretterer avatar bretterer commented on July 22, 2024

The error you were experiencing in this issue should be resolved with an install of okta through pip with version 1.0.1

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on July 22, 2024

with version 1.0.1, this seems to work

from okta.client import Client as OktaClient
import asyncio

async def main():
    client = OktaClient()
    users, resp, err = await client.list_users()
    print(len(users))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
# asyncio.run(main()) # gives an error in Windows (but not in Ubuntu)

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on July 22, 2024

here's a hello world for pagination. the example in the readme is confusing. it seems to be 3 different examples (which is fine, but could be made clearer). note that has_next() is a function.

from okta.client import Client as OktaClient
import asyncio

async def main():
    client = OktaClient()
    users, resp, err = await client.list_users()
    while True:
        for user in users:
            print(user.profile.login)
        if resp.has_next():
            users, err = await resp.next()
        else:
            break

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

from okta-sdk-python.

bretterer avatar bretterer commented on July 22, 2024

This will be resolved by #128

from okta-sdk-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.