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.