Building OAuth Strategies with passport.js Chapter 7
The preceding command should add the package to your package.json file:
"node-sass": "^4.7.2",
"nodemon": "^1.14.10",
"passport": "^0.4.0",
"passport-twitter": "^2.1.1",
Configuring Passport's Twitter Strategy
Just like Facebook Strategy, we have to perform the following steps to configure passport's
Twitter Strategy:
- Creating and setting up a Twitter application. This will provide us with a
consumer key (API Key) and a consumer secret (API Secret). - Adding a button to our login page that allows our users to LOGIN WITH
TWITTER. - Adding the necessary routes.
- Adding a middleware method to check authentication.
- Redirecting the user to the home page after redirection and displaying the
logged-in user's email in the top bar.
Let's dive into the details for each of the preceding steps.
Creating and setting up a Twitter app
Just as with Facebook Strategy, to be able to use the Twitter Strategy, we have to build a
Twitter application as well. The developers' portal for Twitter is at https://apps.twitter.
com/, where you will see a list of all of your applications. If this is new, you will see a
button to create a new application—click on Create your Twitter application.