Use TOTP with nitrokey and privacyIDEA

Hello,

I want to use a Nitrokey 3 with privacyIDEA. I created TOTP with nitropy by nitrokey:

nitropy nk3 secrets add-otp --kind TOTP mfa 23456723456723456723456723456723

Nitrokey needs a base32 secret. However, if I have enrolled the TOTP token with privacyIDEA; the TOTP token verification failed (ERR905: Verification of the new token failed.)

What do I wrong?

import secrets

secret: bytes = secrets.token_bytes(20)

privacyidea_secret: str = secret.hex()
nitrokey_secret: str = base64.b32encode(secret).rstrip(b"=").decode()

You already saw it.

PrivacyIDEA expects an hexflified OTP secret.

I would recommend writing a small script that

  1. create the secret key (either using nitropy or privacyidea or a third way)
  2. calls nitropy to initialize the nitrokey
  3. use the privacyIDEA API to create the token within privacyIDEA. (see 15.1.1.10. Token endpoints — privacyIDEA 3.10dev1 documentation)

I created such a script using nitrocli once, I have not used nitropy, yet.