Nick
Nick

Reputation: 315

"Could not authenticate you" during friendships/create using twit npm package

I have a NodeJS applications that interfaces with Twitter through the twit library. I'm using both the streaming and the REST api in my application. Streaming works nice, some to the REST calls too, but for some reason,

twit.post('friendships/create', {
      screen_name: tweet.user.screen_name,
      follow: false
    }, function (err, resp) {
      if (err) {
        return console.log('friendship gave error: ' + JSON.stringify(err));
      }
      console.log('friended');
    });

always returns an error:

friendship gave error: {"message":"Could not authenticate you","statusCode":401,"code":32,"allErrors":[{"message":"Could not authenticate you","code":32}],"twitterReply":"{\"errors\":[{\"message\":\"Could not authenticate you\",\"code\":32}]}"}

I'm pretty sure I am authenticated properly, otherwise the other calls to twitter would'nt work... Any thoughts?

Thanks! nick.

Upvotes: 0

Views: 895

Answers (1)

Nick
Nick

Reputation: 315

Found the issue: twit library doesn't properly deal with booleans as arguments for calls: I changed

``` follow: false ``

to

follow: 'false'

and the problem was solved.

Nick.

Upvotes: 1

Related Questions