How can I use the python Okta SDK to grab one specific user?

Hi, I want to grab the data of one specific Okta user using the python SDK. The documentation specifies I use get_user(user.profile.login) but it returns a NameError saying name ‘user’ is not defined. I think this is an issue with not defining which user I want to grab? Where would I specify which login I want to use? I want to grab a user’s data by searching their login (first.last)

Here is my code:

config = {
    'orgUrl': 'https://censoredforprivacy.okta.com',
    'token': os.environ['OKTA_API_TOKEN']
}
okta_client = OktaClient(config)


async def GrabOktaUser(UserLogin):
    users, resp, err = await OktaClient.get_user(user.profile.login)
    print(resp)
    return resp

Hi everyone, I solved my own issue. I was using the wrong name for the Okta client (For me it was okta_client not OktaClient) and to search you just enter the user id. So replace "user.profile.login’ with ‘first.last’

Here is the proper code:

config = {
    'orgUrl': 'https://censoredforprivacy.okta.com',
    'token': os.environ['OKTA_API_TOKEN']
}
okta_client = OktaClient(config)


async def GrabOktaUser(UserLogin):
    users, resp, err = await okta_client.get_user('first.last')
    print(users)
    return users
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.