Home > Software design >  Twitter API oauth/request token page does not exist
Twitter API oauth/request token page does not exist

Time:10-22

Using node twitter package https://www.npmjs.com/package/twitter Twitter: https://developer.twitter.com/en/docs/authentication/oauth-1-0a/obtaining-user-access-tokens

I'm trying to post a tweet for someone.

Tell me what's wrong with this:

var Twitter = require('twitter');

const client = new Twitter({
    consumer_key: process.env.TWITTER_CONSUMER_KEY,
    consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
    access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
    access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
});

client.post('oauth/request_token', {oauth_callback: process.env.CALLBACKURL})
    .then(response => {
        console.debug('got twitter token',response);
        res.redirect('https://api.twitter.com/oauth/authenticate?oauth_token='   response.oauth_token)})
    .catch(function(err) {
        console.error('failed to authenticate twitter', 'twitter-lite', err, res.locals.host);
        console.log(err);
    });

[ { message: 'Sorry, that page does not exist', code: 34 } ]

I'm having trouble with the simplest things while trying to use the twitter API. Doesn't help that there's no good examples.

CodePudding user response:

The module you're trying to use has not received any updated in the past 4 years. It's somewhat likely that in that time, Twitter has changed the URLs they're using for authorization/authentication.

You should probably be using something a bit more up-to-date, like twitter-api-v2.

  • Related