This is an Express application using Google for authentication via OAuth2 and Local Email and Password authentication. Both running simultaneously
We can create a client ID and client secret using its Google API Console. You need to follow below steps once you open Google API Console
- From the project drop-down, select an existing project, or create a new one by selecting Create a new project
- In the sidebar under "APIs & Services", select Credentials
- In the Credentials tab, select the Create credentials drop-down list, and choose OAuth client ID.
- Under Application type, select Web application.
- In Authorized redirect URI use http://localhost:3000/auth/google/callback
- Press the Create button and copy the generated client ID and client secret
Note: If Google doesn't support http://localhost:3000, then use http://127.0.0.1:3000
git clone https://github.com/Bunty9/passport-google.git myapp
cd myapp && npm install
- Create a .env file in the root directory on package.json level
- Add GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and SESSION_SECRET to .env file
- also define PORT and MONGO_URI in the .env file
run npm start
Open http://localhost:3000 with your browser to see the result.
You can check out My GitHub repository - your feedback and contributions are welcome!