Simple passportjs google oauth strategy with mongodb, ES6 style…

Extending upon previous example of creating a simple es6 based mongodb authentication with passportjs, google-strategy of passportjs also added and worked with just addition of clientid and secret from google developer account Credentials of Google dev API.

What happens here is just adding a new URL for login like http://serverip/auth/google and give the google authentication a callback via somet url like http://serverip/auth/google/callback.

The callback will contain the profile details of user along with a specific unique google id. So we use this id to match across to the user if he logs in again. Store all the relevant webapp information using this id. You have to configure the google API in OAuth2 credentials manager.

You can the branch with google-strategy working in here:

You would have to change clientid, secret as per your Google account API credential specifics.

Leave a Reply

%d bloggers like this: