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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access