Hi,
Is there a way to programmatically create an OTP Device for a django superuser without doing it manually via the admin interface?
I am able to register the device manually via the admin page, but I would like to be able to tear down my whole application and re-create it from the code, without having to register a device manually every time. As part of the deployment script, I am creating automatically the super user, but I haven't found a way to automatically create the Device and associate it with the user.
In other words, I would like to take an existing Device (with existing key) that I previously registered with a QR code, and being able to recreate it automatically once I recreate my model.
Would something like that work and be a clean way to do it, or is there any other existing methods that should be used to do that?
from django_otp.plugins.otp_totp.models import TOTPDevice
# Register phone for 2 factor authentication
device = TOTPDevice(user=user, name="Phone", confirmed="True", key="vcbd5fd66f453d578fg45f479fa2d349fsg54dc49d")
Thank you
Regards
Yann