Getting 403 Forbidden on user_timeline but not on any other API

Using the auth API

  var oauth2 = new OAuth2('Consumer Key', 'Consumer Secret', 'https://api.twitter.com/', null, 'oauth2/token', null);
  oauth2.getOAuthAccessToken('', 'grant_type': 'client_credentials' }, function (e, access_token) {

      console.log(access_token); //string that we can use to authenticate request

      requestURL = {
          url: 'https://api.twitter.com/1.1/statuses/user_timeline?user_id=' + userid,
          headers: {
              Authorization: 'Bearer ' + access_token
          }
      };




request(URL, function(error, response, body){ 
    console.log(request); 
    console.log(body); }

      

With this code I am getting 403 Forbidden, but with the same code on other APIs like search / tweets, it works great. What am I missing here? And no, the user is not private.

+3


source to share


1 answer


You have an error in the url you are calling. It should be:



...
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?user_id=' + userid,
...

      

0


source







All Articles