Search code examples
pythonokta

Okta Python SDK - how to obtain state token


Hi I am trying to use the Okta Python SDK to change the password of a user. One of the required parameters is the state token. It isn't clear to me as to how I can get hold of a state token to begin with. I was unable to find any relevant examples in the available documentation. Can someone please help me with this ?


Solution

  • If you are looking to change the password of a user, you can call the change_password() method using the UsersClient.

    A state_token is only required when changing a user's password during the authentication flow.

    from okta import UsersClient
    
    usersClient = UsersClient("https://example.okta.com", "API_KEY")
    
    changed_user = usersClient.change_password("USERNAME",
                                               "OLD_PASSWORD",
                                               "NEW_PASSWORD")