Few scripts to operate on UD
Python scripts that demonstrte use of Okta's REST APIs for Unviversl Directory. Description of each script
- activate_staged_users.py -> Activates all STAGED (Pending activation) users in the org.
- create_random_users.py -> Create N number of random users in org. Helpful in case when you want to create bunch of users for testing
- get_all_active_users.py -> Retrieve all active users from org and write them in csv
- get_app_assignment_events -> Capture app assignments done by admin, in csv file.
- set_attribute.py -> Set any attribute (attributeName in the script) to a value (attributeValue) for all users in org
- delete_users.py -> Delete all deactivated users in the Okta tenant.
Last ud_script_template.py is a template. It has functions to make REST API calls (GET, GET paginated, POST, PUT and DELETE). This script can be used to create any use case. Test the use case in Python and use this script to create same flow using functions.
- Python 2.7
- Python's requests libaray (run "pip install requests" from command line or shell). You may need t install pip i.e. Python's package manager on Windows system
For all scripts open the script in your favorite editor (e.g. Sublime) and set following variables
orgName: including okta/oktapreview to your org e.g. "myorg.okta" or "myorg.oktapreview" apiKey: API token from Okta org (Security -> API -> Token)
If there are any required attribute such as N, attributeName, attributeValue at the top, update those to yoru need as well.
In command prompt or shell navigate to folder where Python script is copied "cd ~/Documents/PythonScripts" and run the script e.g "python activate_staged_users.py"