Configuring Passport's Google strategy
The configuration for all the strategies is somewhat similar. For the Google strategy, the following are the steps we have to follow for configuration:
- Creating and registering an application on Google. 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 log in via Google.
- Adding the necessary routes.
- Adding a middleware method to check authentication.
- Redirecting the user to the home page 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 Google app
Just as we did for the Facebook and Twitter strategies, to be able to use the Google Strategy, we have to build a Google application. The developers, portal for Google is at https://console.developers.google.com/.
Then, click on the drop-down list of the projects, which lies at the top-left corner of the page. A popup will show...