ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.31k stars 568 forks source link

Login a user #479

Open Neuroforge opened 6 years ago

Neuroforge commented 6 years ago

Hello,

If a user is not logged into twitter.

How can i, given their username and password, log them in and then continue to use Twit?

From the documentation, it appears

https://developer.twitter.com/en/docs/basics/authentication/overview/oauth

  1. User authentication aka user context The user authentication method of authentication allows an app to act on behalf of the user, as the user. Example: if a developer wanted to build a feature that would allow a user to post Tweets through their platform using the statuses/update endpoint, the developer would have to use user authentication to get permission from the user to post a tweet on their behalf.

In other words, a signed request identifies an application’s identity in addition to the identity accompanying granted permissions of the end-user the application is making API calls on behalf of, represented by the user’s access token.

User authentication requires the consumer key and secret from your Twitter app and the access token and access token secret from the user you are trying to act on the behalf of.

Regards,

Daniel

maziyarpanahi commented 6 years ago

Hi @Neuroforge What is it you are trying to do with twit library? If it is just authenticating the user, then this is not the right library. You have to look for a library that allows third-party authentications by Twitter, Facebook, Google, etc. twit is only for dealing with Twitter rest APIs.

Neuroforge commented 6 years ago

Can you recommend an auth library for javascript?

I looked at react-twitter-auth but it has issues.

maziyarpanahi commented 6 years ago

I had successfully used Passport.js for Twitter auth with callback. Not sure about the new versions and with new Twitter policies.