Skip to main content

Bulk Update the Enrollment User (auth_username) using API

What

This problem and solution came from a customer who had many devices in FileWaveFileWave, butyet did not have the 'Enrollment UserUser' (internally known as auth_username) populated. In order for automatic associations of iPads to happen inwith Apple Classroom, youdevices need tomust have thean Enrollmentenrolment Useruser set for your devices.set. While it’s possible to set thisthese one by one, that does not scale well. ForEven hosted customers,customers could benefit from this is a solution that would be able to be run by you rather than you having to contact support.

Because it can be a topic that can trip someone up it is important to note that API calls are normally done on TCP 443. You may see references to 20445 in some documentation, but that is the RESTful API (v1 API) and it is on TCP 20445 however you can make a small change in the URL for the API endpoint and use TCP 443 for all calls by prepending /api/ on to the /inv/api/ URLs to make it /api/inv/api/ in the URLs.example.

When/Why

The below solution leverages the FileWave API and is a great example that any customer could build. You can run this script from your mac, Windows, or Linux computer, and it will talk to the API and make the changes in bulk.

How

  • The first step is to download the script:

    FileWave Download.png
  • Once downloaded, you will have a zip file containing the bulk_change_device_authname.py script and an auth_username.csv file where your changes will be placed.

  • Unless you are running the script directly on a CentOS or macOS based FileWave Server, you will need to edit the script’s first line to point at where Python is located on your system. In my case, on my macOS system, it was #/usr/local/bin/python3 as I had installed Python from https://www.python.org/downloads/ This process should work on any OS that supports Python scripts, and on Windows, you can use the same URL to download Python for Windows. There is good documentation on using Python on Windows here: https://docs.python.org/3/using/windows.html

  • The next step would be to edit the auth_username.csv file to contain the Device IDs of the devices and the Enrollment User values you would like. Do not change the first row from “Device ID” and “Enrollment Username” because the script looks at that. Also, do not add additional columns to the CSV. The best way to do this is to use FileWave to make a Query of your devices and include Device ID as a field. Export that and then use something like Microsoft Excel to marry the data with your list of Enrollment Users. Ultimately produce a file that has just the Device IDs and Enrollment Users.

bulk-update-api-query.png

  • The final step is to look in your FileWave Admin for the Token you would need. Below is an image showing the Token in an example setup. Note that usually, in our examples, the base64 version of the token is used, but this script uses the Token itself. In my example, I used the user bob, but I made sure that the username had the required permissions to change custom field data. If you only have fwadmin then use that as that user will always have the needed permissions.

api-key.png

You can now run the below from Terminal.app on your mac or similarly on a Windows or Linux system that has Python.

./bulk_change_device_authname.py --token {b5cb89a0-fe59-4cb1-9359-d72b79369c0} --host ExampleCo.filewave.net --mapping ./auth_username.csv

The script will give you feedback about the success or failure of any records.

If you are missing a Python module like requests, you can usually easily add it with a command like below and note that you should change the path to Python if it isn’t in the location below. You’ll know that you are missing it because the script will give an error like requests not found.

/usr/local/bin/python3 -m pip install requests

At this point, you should have success, and you should look at this script as a great example of how to do bulk actions using a CSV file against your FileWave server. This can easily be transformed into a script that does just about anything in bulk.