Google Strategy

Introduction

Passport Google authentication strategy using OAuth 2.0

Configuration sample object

Below is a configuration sample that is needed for the Google strategy to be configured. Follow the steps below the sample to get those configurations.


Configuration Sample
"google": {
    clientID: '%client_ID%',
    clientSecret: '%client_secret%',
    callbackURL: '%client_callback%'
}


Configuration Steps

1 - Create a Google credentials (you must have a project created on Google Developers).

You must register an OAuth client ID with Google in Google Console in Google's credentials.

You have to insert the Application Type (Web Application on our case)

Set the callback URL and save.

After saving, it will pop-up a modal with your information, or you can go to OAuth 2.0 client IDs, on Credentials page, and click to Edit OAuth client, to see the clientID and clientSecret.


2 - Strategy Configuration

The passport-google strategy authenticates users using a Google user account and OAuth 2.0 tokens. Client ID and Secret granted in the creation of an app should be added to the config file as options so the strategy will be created. The callback URL will be used to receive the access-token, refresh-token, and profile which is the Google authenticated user profile.