Skip to content

tsamaya/passport-example-with-google-oauth2

Repository files navigation

passport-example-with-google-oauth2

This repository is a Passport example using an Express application with an authentication using Google-OAuth2 authorization.

Usage

Create an OAuth 2.0 client ID

First, create a project at console.developers.google.com

Create authorization credentials

  1. Open the Credentials page in the API Console.

Google console

  1. Fill the form for in the Oauth consent screen tab, only the Product name shown to users is mandatory

Google console

  1. Back in Credentials tab, Click Create credentials > OAuth client ID.

  2. Complete the form. Set the application type to Web application. Fill the Authorized redirect URIs, here with our local server use http://127.0.0.1:3000/auth/google/callback.

  3. click Create

Enable Google+ Library

  1. Open the Library page in the API console.

  2. Search for Google+ API

Google console

  1. Enable this API

Google console

Configure Strategy

create a .env file with:

GOOGLE_CLIENT_ID=YOUR-CLIENT-ID
GOOGLE_CLIENT_SECRET=YOUR-CLIENT-SECRET

Install dependencies

$ npm install

or

$ yarn

Run

$ npm start

or

$ yarn start

open your browser on localhost:3000

Home

Resources

Contributing

Anyone and everyone is very welcome to contribute.

Issues

Find a bug or want to request a new feature? Please let me know by submitting an issue.

Licensing

Licensed under the MIT License

A copy of the license is available in the repository's LICENSE file.

Releases

No releases published

Packages

No packages published