Automatic generation of TAN lists for multiple users

Dear Sir or Madam,

is it possible to automatically generate a TAN list per user for several users?

I imagine the whole thing as follows:
I have a CSV file with several users that I can import. As soon as the CSV file has been imported, a TAN list (with X-TANs, e.g. 100) is automatically generated and saved for each user in this file.

or alternatively:
As an admin in PrivacyIDEA, I can select the required users via multiple selection and then execute an action which creates and saves a separate TAN list for each of the selected users.

Thank you very much!

You could use the REST API of privacyIDEA. Something like:

with open("user.csv", "r") as users:
    for username in users:
        response =
                "otpkey": "1",
                "type": "tan",
                "user": username,


And then you could probably get the tan list as response.

1 Like

You can not do this multi-action in the UI.

You can use the REST API to automate tasks as @rob showed, or you can use the library level.
On the privacyIDEA server itself you can use the privacyidea python modules to write python scripts, that go around the REST API and directly modify the system.

This way you can create users, generate tokens (privacyidea.lib.token:token_init()) and basically everything you want to do.

Please note, that defined event handlers are triggered by the REST API but not by library calls.

You can find example scripts here:

Here is an example, that creates users from a CSV, uses assign_token for existing tokens and init_token to create new tokens.

1 Like

Many thanks for the quick responses @rob @cornelinux
We have now solved it via RestAPI with a Powershell script! :slight_smile: