Enroll sms token type via API (token/init)

Hello

I am trying to use the API to enroll an sms token to a user. I have been using the dotnet provider found here:

Whenever I call enrollSMSToken which is mapped to /token/init the token created when I view via the admin UI is not type sms but type HOTP.

I POST to /token/init?genkey=1 and supply the following parameters:

                    {"type ", "sms"},
                    {"user", OTPuser},
                    {"realm", realm},
                    {"phone", phonenumber}

I cannot find phone on the list of parameters here in the docs for token/init so wonder if I am not passing the right/required parameters:

I was wondering where I can find an example of using the API to enroll sms tokens?

Thanks

I do not know, if this code you mentioned works.

You can enroll an SMS token by issuing a POST request with the parameters

  • genkey=1
  • type=sms
  • phone=phonenumber

See https://privacyidea.readthedocs.io/en/latest/modules/api/token.html#post--token-init
Maybe you want to checkout outside of this code.

Many thanks for the prompt response.

So I tried a POST request with those 3 parameters but the token created is still of type hotp. I can create type sms via the UI without a problem.

I have configured Twilio as an SMS Gateway I wondered if there is anything else that could be causing this to happen?

Thank you

Open the developer mode of your browser.
Create an SMS token in the WebUI
…and what the POST request.

I suspect that your client, which you are using trying to issuing the request, is broken.