How to create registration token with otpkey paramter with REST API?

Hello,

I want to create a registration token with with the REST API.

session_token = get_session_token()
headers["Authorization"] = session_token

response = requests.post(
    "{PRIVACYIDEA_URL}/token/init",
    headers=headers,
    data={
        "otpkey": "1234",
        "type": "registration",
        "user": "test",
    },
)

print(response.json())

But the API ignore the otpkey and returns other registration codes, e.g. like “rX5>j]=gSa;”“M>J~.t.5&z<”.

What do I wrong?

It looks like the registration token will always be generated by privacyIDEA.
it defaults to genkey=1.

However, you can have enrollment policies to define the length and the contents of the generated registration code.
https://privacyidea.readthedocs.io/en/latest/policies/enrollment.html#registration-length

Always take a look at the policies :wink:

1 Like