twit icon indicating copy to clipboard operation
twit copied to clipboard

"Error: Could not authenticate you." when sending DM

Open takuoka opened this issue 6 years ago • 1 comments

Code

    const params = {
      event: {
        type: "message_create"
        , message_create: {
          target: {
            recipient_id: "99999999"//my account
          }
          , message_data: {
            text: "MESSAGE"
          }
        }
      }
    };

    client.post("direct_messages/events/new", params, function(error, data, response){
      if(!error){
        // success
      }
      else {
        console.log(error);
      }
    });

Error

{ Error: Could not authenticate you.
    at Object.exports.makeTwitError (/MY_PROJECT/node_modules/twit/lib/helpers.js:74:13)
    at onRequestComplete (/MY_PROJECT/node_modules/twit/lib/twitter.js:344:25)
    at Request.<anonymous> (/MY_PROJECT/node_modules/twit/lib/twitter.js:364:7)
    at Request.emit (events.js:187:15)
    at Gunzip.<anonymous> (/MY_PROJECT/node_modules/request/request.js:1079:12)
    at Object.onceWrapper (events.js:273:13)
    at Gunzip.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  message: 'Could not authenticate you.',
  code: 32,
  allErrors: [ { code: 32, message: 'Could not authenticate you.' } ],
  twitterReply: { errors: [ [Object] ] },
  statusCode: 401 }

takuoka avatar Aug 22 '19 08:08 takuoka

The recipint_id should be the person receiving the message, not you. But by the error message I don't think that's your only problem, maybe your API keys are incorrect?

friaca avatar Oct 11 '19 19:10 friaca