Book Image

Building Scalable Apps with Redis and Node.js

By : Joshua Johanan
Book Image

Building Scalable Apps with Redis and Node.js

By: Joshua Johanan

Overview of this book

Table of Contents (17 chapters)
Building Scalable Apps with Redis and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding Google authentication to our application


First, we need to add our Google-specific information to our config. Open config.js and add the following lines:

routes: {
    login: '/account/login',
    logout: '/account/logout',
    chat: '/chat',    facebookAuth: '/auth/facebook',
    facebookAuthCallback: '/auth/facebook/callback',
    googleAuth: '/auth/google',
    googleAuthCallback: '/auth/google/callback'
  },
//host and facebook
google: {
    clientID: 'YOUR_GOOGLE_ID',
    clientSecret: 'YOUR_GOOGLE_SECRET'
  }

We haven't added anything different. We just had to create the two Google authentication routes and add the ID and secret.

The package we will use is passport-google-oauth. This should be installed already at this point through npm install. Notice that this is not passport-google. That package is used to authenticate with OpenID, and we want to use OAuth2.

Open index.js present in the passport folder and add a reference to our Google strategy as follows:

//other variable declarations...