To delete users in bulk, we provide a script that reads a CSV file and performs user deletions using the OneLogin OAuth API. You can download the script zip file using this link:
Ruby 2.2.2 with rest-client 2.0.1 gem
To install the gem, run
$ gem install rest-client
Create a CSV file that includes the users you want to delete from OneLogin.
The file should include a header row with column names in lowercase. It should include at least one of the following columns:
- User ID of each user (with column heading id)
- Username of each user (with column heading username).
- Email of each user (with column heading email).
Get an API credential pair (Client Secret and Client ID).
See "Working with API Credentials" at developers.onelogin.com.
Create credentials with a minimum scope of Manage users.
delete_users.zip(above) and unzip it.
In a terminal, change to the directory where you unzipped the download.
Run the following command, replacing the options as specified below.
$ ruby delete_users.rb env=<us|eu|de> file=<your_filename> client_id=<your_client_id> client_secret=<your_client_secret> dry_run=false
<us|eu|de>is the location where your OneLogin account resides.
<your_filename>is the path to your csv file.
<your_client_id>is the Client ID from the API credentials you got in step 2.
<your_client_secret>is the Client Secret from your API credentials.
$ ruby delete_users.rb env=us file=onelogin/users.csv client_id=abc123def456 client_secret=456def123abc dry_run=false
Note. To do a "dry run" of the script, change
dry_run=true. The script will print what the command would do without actually executing the command.
Go to your OneLogin account and confirm the deletions.