I want to authenticate with Twilio's api using the Node.js https module. My code is essentially:
const options = {
host: 'api.twilio.com',
path: '/2010-04-01/Accounts/' + TWILIO_ACCOUNT + '/Messages.json',
auth: {
user: TWILIO_ACCOUNT,
pass: TWILIO_API_KEY
}
};
const req = https.get(options, (res) => { ...
The error I receive is TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object. If I remove the auth argument in the options:
const options = {
host: 'api.twilio.com',
path: '/2010-04-01/Accounts/' + TWILIO_ACCOUNT + '/Messages.json'
};
const req = https.get(options, (res) => { ...
the error I receive is Authentication Error - No credentials provided. This leads me to believe I am not passing the authentication correctly in the options.
( Using request-promise, this method of passing the authentication works; I was trying to see if I could get it to work using a Node.js built-in module )