node.jsfluttermessagebird

Messagebird SMS authentication/ OTP for mobile app with node js and flutter


I'm trying to send SMS OTP via MessageBird services with nodejs and flutter application.

I tried the configuration and calls that doing on this video (official from MessageBird) but I cannot understand what is going on with ID that I'm getting back and the token that I should post it to Messagebird's API.

Video link: https://www.youtube.com/watch?v=6wrThyJi7lo

Any one can help me ?

Thank you very much!


Solution

  • In short:

    the ID is for the verification process, when you send the ID and the token together back to messagebird in step3 of the tutorial, messagebird will tell you if this token you just sent is the one that was sent to the user.

    The flow works like this:

    1. your application gets a phone number from the user
    2. your application makes a verify request using messagebird sdk (where it calls messagebird.verify.create(number, {"template": "<message_template>"}...)
    3. Messagebird will replace %token from your <message_template> with a random token and send a message to the user's phone.
    4. if the verify.create request succeeds, messagebird will give you an ID for this verification process, you'll need that later to verify the token when the user submits it to you
    5. The user gives you a token and you pass it back along with the ID (from the previous step) to messagebird where you call messagebird.verify.verify(id, token, ...)
    6. Messagebird will respond back to your request with either success or error based on whether the token matches what was sent to the user or not.

    more details: you need the ID and the token in order to be able to handle multiple users at the same time, think if u have two users verifying their phone number at the same time, one got token 1234 and the other got 5678 without an ID there's no way to tell them apart.