Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
How to use the Twit NodeJS Library to get user access token

I am tring to use the Twit NodeJS library to get an access token on behalf of a Twitter User. I tried implementing the Oauth workflow myself but I keep getting Bad Authentication Data as response from Twitter.

My Application is not an app only app. I need the user to consent to and sign in and allow my app to get an access token so I can publish tweets on behalf of the user.

It's not clear how to proceed on that using the Twit library.

From the Twitter documentation, I was told I need to first of all call /oauth/request_token to get an oauth_token and then call oauth/authorize with that oauth_token for the user to authorize, save the returned access token somewhere and then make further api calls using that access token.

Please how can the above be achieved using this library.

Here is the code I tried

  let T = new Twit({
        consumer_key: oAuthConsumerKey,
        consumer_secret: oAuthConsumerSecret,
        callback: oAuthCallbackURL,
        app_only_auth: false
    });
    T.post('oauth/request_token', {}, (err, data, response) => {
        console.log(`Twitter Response=${response} err=${err} and data=${data}`);
    });

Here is the error I Ended up with:

Error: Twit config must include `access_token` when using user auth.
2021-09-21T02:14:38.530586+00:00 app[web.1]:     at /app/node_modules/twit/lib/twitter.js:511:13

I tried posting this on the library issues list but no one is responding and I'm way behind deadline so I'm currently desperate at getting this to work.

Any insights to resolving this would be greatly appreciated. Thank you.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!