0
votes

I'm trying to get twitter request token and access token using node-twitter-api

here is my code

twitterAPI = require('node-twitter-api');
 function setSettingForTwitter(request, response, sessionManager) {
        var twitter = new twitterAPI({
            consumerKey: '1YTLohgHVA9L2Mri0bM2692Rl',
            consumerSecret: 'sGlYSxrs1uhS7v8qGY5fb2S8xLeNT2nACmchpONcjHO0bMfmzo',
            callback: 'http://localhost.com/app/socialNetworkSetting/respondFromTwitter'
        });


    twitter.getRequestToken(function(error, requestToken, requestTokenSecret, results){
        if (error) {
            console.log("Error getting OAuth request token : " , error);
        } else {
            //store token and tokenSecret somewhere, you'll need them later; redirect user
        }
    }); }

but I receive the error below

Error getting OAuth request token : { statusCode: 401, data: '\n\n Desktop applications only support the oauth_callback v alue \'oob\'\n /oauth/request_token\n\n' }

help me on this please!

1

1 Answers

1
votes

Looking at this post it says:

If you're getting this error, it means that you haven't configured your application to accept dynamic URL-based callbacks. You can enable this behavior by providing a placeholder callback URL on your application detail edit screen.

So you would need to

  1. Login to your Twitter account and go to your app where you got your consumerKey value and load the detail edit screen.
  2. Add a placeholder callback - it can be any URL I believe as it is just a placeholder eg. https://example.com/controller/method.