Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda