Authenticating Using Google

The code in Listing 26.16 shows the basics of implementing a Google authentication strategy using Passport. The /login displays a login page with a simple link to log in via Google. The /info route displays profile information from the Google authentication.

Notice that both the /auth/google and /auth/google/return routes are implemented, and the user is redirected to /info. The serializeUser() and deserializeUser() methods alter the user object because you are not using MongoDB storage for this example.

Listing 26.17 implements the login.html template that is used to display the Google login link. Listing 26.18 implements the user info page, which displays the identifier, displayName, and email address returned from ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.