0

This is our use case:

  1. We have an ASP.NET MVC website in C#. When user goes to the login page, they enter their email and password.
  2. My C# code in the MVC action method checks the password against the database, and it is valid.
  3. My C# code sends a request to Twilio, and Twilio pushes a notification to a generic Twilio or third-party authentication app on the user’s mobile (note we don’t want to develop this app), which shows an “Approve” and “Deny” button.
  4. User presses the “Approve” button, and the response is returned by the app to Twilio.
  5. My code got notified, and logs user in.

Following is a diagram of the above process:

enter image description here

Can someone kindly point me to some documentation or sample code specifically for this use case please?

1 Answers1

0

Twilio developer evangelist here.

The product you are looking for here is Twilio Authy Push authentication. It will push the notification to the Authy application when your user has it installed. You can also fallback to SMS or provide a QR code that allows users to use TOTP with their own choice of authenticator app.

You can check out the documentation on implementing Authy Push in C# in the Twilio docs.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • hi Phil, I executed the sample code at "https://www.twilio.com/docs/authy/api/users" to create a new user, and I got the following error: {"email":"is invalid","message":"User was not valid","success":false,"errors":{"email":"is invalid","message":"User was not valid"},"error_code":"60027"} –  Dec 07 '20 at 03:12
  • Did you try that with your own email or did you use the fake one in the documentation? – philnash Dec 07 '20 at 03:13
  • I used my own email and phone number, in the form of 61 as Australia's country code, and "411222333" as my mobile number. (my real phone number is different). –  Dec 07 '20 at 03:39
  • Hoops! I had a typo. Now it came back as "success". Many thanks Phil! –  Dec 07 '20 at 03:41
  • 1
    Ah, good news! I was a bit lost myself as to what to suggest next – philnash Dec 07 '20 at 03:42
  • Hi Phil, how do I parse the returned JSON string? I hope Twilio C# API would have some read-made class for this purpose? Or do I have to write my own class or use dynamic object? –  Dec 07 '20 at 04:20
  • 1
    There is the [Authy.NET](https://github.com/twilio/authy.net) library that will make requests and parse the results for you, but it is deprecated. Alternatively you could use [Json.NET as suggested in this answer](https://stackoverflow.com/a/6620173/28376) to parse the JSON yourself. – philnash Dec 07 '20 at 04:48