desmondmorris / node-twitter

Client library for the Twitter REST and Streaming API's.
https://www.npmjs.com/package/twitter
MIT License
1.27k stars 237 forks source link

Error: HTTP Error: 401 Unauthorized #350

Closed gumernus closed 3 years ago

gumernus commented 3 years ago

when I try to send a tweet it will write this:

Error: HTTP Error: 401 Unauthorized
    at Request._callback (D:\programing\node_things\node_modules\twitter\lib\twitter.js:221:9)
    at Request.self.callback (D:\programing\node_things\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (D:\programing\node_things\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (D:\programing\node_things\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

this is my code:

var Twitter = require('twitter');

var client = new Twitter({
  consumer_key: 'oBNnC2azUurLYr5mfn2RYegt1',
  consumer_secret: 'YfsKR60cv5YJOishMM1XAqZSe7la2ZDRoJjiRVAeD71zvy8zDA',
  access_token_key: '1349452854197706754-9t5U7wOmQCRmrW4rjCKf8HyXYIMM6I',
  access_token_secret: 'HCX9YghNjnV8nruAF0DJWhO6ep8Ca6gbpLnm9o1S4JcDR'
});

// var params = {screen_name: 'michal_lmao'};
// client.get('statuses/user_timeline', params, function(error, tweets, response) {
//   if (!error) {
//     tweets.forEach(function(tweet){
//         console.log(tweet.text);
//       });
//   }
// });

client.post('statuses/update', {status: 'lmao jsem gut'}, function(error, tweet, response) {
    if (!error) {
      console.log(tweet);
    }
    else{
        console.log(error)
    }
  });