[SOLVED] Auth problem with electron twilio webhook

Mod Edit (@harrisonhjones): Solution: See this post

Hi,

I’m trying to set up an SMS notifcation when a switch is tripped.
I am using an electron with a particle SIM so I know I cannot do this directly but should be able to through a webhook. I have got a webhook working OK to send an email when the switch is tripped using mailgun thanks to Webhook Tutorial - Send an Email!.

However I would much prefer to use SMS for the notification and have spend a day or so trying to get it working with twilio, having followed various posts and particularly Webhooks + Sending a text message.

However I keep getting 401 ( auth errors) from the twilio webhook. I have checked that my details are correct. and have tried with both my user id and password and Sid and token in th eauth section to no avail

this is what I am using:

{
    "eventName": "Switch1Trip",
    "url": "https://api.twilio.com/2010-04-01/Accounts/MY TWILIO ACCOUNT SID/Messages",
    "requestType": "POST",
    "auth": {
        "username": "MY TWILIO USER NAME",
        "password": "MY TWILIO PASSWORD"
    },
    "form": {
        "From" : "TWILIO_PHONE_NUMBER",
        "To" : "MY_PHONE_NUMBER",
        "Body" : "Switch 1 tripped"
    },
    "mydevices": true
}

What do I need to change to get twilio to send the text?

thanks

In your webhook definition you don’t seem to have the double quotes around around MY TWILIO USER NAME and MY TWILIO PASSWORD

Is this a mistake in the post or in your actual webhook definition?

The error was in the posting, the values are in double quotes, I have edited the posting now . Thanks for pointing it out.
Still would like to find solution to this problem.

Please does anyone have a suggestion for how to overcome this auth problem?

Could you try connecting to it with something like Postman to make sure things are set-up correctly on the receiving end?

Thanks All, I have solved it. the trick ACCis that though the json above in the auth lines says

    "username": 
    "password":

the values to put after them are not the twilio user name and password password, but the SID and Auth Key.

The correct json is therefore:

{
    "eventName": "Switch1Trip",
    "url": "https://api.twilio.com/2010-04-01/Accounts/MY TWILIO ACCOUNT SID/Messages",
    "requestType": "POST",
    "auth": {
        "username": "MY TWILIO ACCOUNT SID",
        "password": "MY TWILIO AUTH KEY"
    },
    "form": {
        "From" : "TWILIO_PHONE_NUMBER",
        "To" : "MY_PHONE_NUMBER",
        "Body" : "Switch 1 tripped"
    },
    "mydevices": true
}

Fantastic …This works great …Thanks