All Projects → Shahzayb → mern-google-login

Shahzayb / mern-google-login

Licence: MIT License
Authentication flow for React & Express.js application using Google OAuth

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to mern-google-login

Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+7217.95%)
Mutual labels:  oauth, oauth2-server, openid-connect
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+30371.79%)
Mutual labels:  oauth, oauth2-server, openid-connect
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+5856.41%)
Mutual labels:  oauth, openid-connect
Spring Security Pac4j
pac4j security library for Spring Security: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 231 (+492.31%)
Mutual labels:  oauth, openid-connect
Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (+533.33%)
Mutual labels:  oauth, openid-connect
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+5276.92%)
Mutual labels:  oauth, openid-connect
Socialloginmanager
DEPRECATED
Stars: ✭ 178 (+356.41%)
Mutual labels:  oauth, google-login
Identityserver
An open-source, standards-compliant, and flexible OpenID Connect and OAuth 2.x framework for ASP.NET Core
Stars: ✭ 223 (+471.79%)
Mutual labels:  oauth, openid-connect
oidc
Easy to use OpenID Connect client and server library written for Go and certified by the OpenID Foundation
Stars: ✭ 475 (+1117.95%)
Mutual labels:  oauth, openid-connect
jax-rs-pac4j
Security library for JAX-RS and Jersey
Stars: ✭ 48 (+23.08%)
Mutual labels:  oauth, openid-connect
Diber-backend
Delivery Service - Spring Boot / Spring Data Jpa / Hibernate / PostgreSQL / OAuth2 Application
Stars: ✭ 22 (-43.59%)
Mutual labels:  oauth, oauth2-server
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (+294.87%)
Mutual labels:  oauth, openid-connect
Assent
Multi-provider framework in Elixir
Stars: ✭ 126 (+223.08%)
Mutual labels:  oauth, openid-connect
External Auth Server
easy auth for reverse proxies
Stars: ✭ 189 (+384.62%)
Mutual labels:  oauth, openid-connect
oauth2-server
A spec compliant, secure by default PHP OAuth 2.0 Server
Stars: ✭ 6,128 (+15612.82%)
Mutual labels:  oauth, oauth2-server
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+4356.41%)
Mutual labels:  oauth, openid-connect
Mern Boilerplate
Fullstack boilerplate with React, Redux, Express, Mongoose, Passport Local, JWT, Facebook and Google OAuth out of the box.
Stars: ✭ 112 (+187.18%)
Mutual labels:  oauth, google-login
Node Oauth2 Server Example
Working oauth2 server with minimal configuration
Stars: ✭ 115 (+194.87%)
Mutual labels:  oauth, oauth2-server
undertow-pac4j
Security library for Undertow: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 35 (-10.26%)
Mutual labels:  oauth, openid-connect
Taroco-Authentication
Taroco-Authentication 统一认证服务
Stars: ✭ 49 (+25.64%)
Mutual labels:  oauth2-server, oauth2-authentication

mern-google-login

⚠️ This tutorial is deprecated. Follow this tutorial instead (https://developers.google.com/identity/sign-in/web/backend-auth)

Note from google: We are discontinuing the Google Sign-In JavaScript Platform Library for web. For authentication and user sign-in, use the new Google Identity Services SDKs for both Web and Android instead.

Authentication flow for MERN stack application using google OAuth 2.0.

This oauth flow is more secure and you don't have to reload your react app and go through multiple redirections to authenticate client.

App flow

Untitled Diagram

And the image blow is from google docs

server_side_code_flow

Installation

1. Clone the repository & install dependencies

git clone https://github.com/Shahzayb/mern-google-login.git

cd mern-google-login

npm install

cd client & npm install

2. Obtain OAuth 2.0 credentials from the Google API Console.

Visit the Google API Console to obtain OAuth 2.0 credentials such as a client ID and client secret that are known to both Google and your application. Don't store your client secret in your React app. You only need client id in your react app to get the authorization grant code. And you should store client secret in node app.

3. Add Authorized JavaScript Origins

Go to Google API Console. And select your project & then add JavaScript Origins Url Capture

This is a url of client side react app

You'll notice in my code that I set the redirect_uri to postmessage, its because we need the authorization grant code without any redirection

4. Client Side Setup

  1. execute these commands
cd client
touch .env.local
  1. open .env.local file & enter REACT_APP_GOOGLE_CLIENT_ID=your client id provided by google

5. Server Side Environment Variables Setup

From the root directory of the project, type:

mkdir config

cd config

touch dev.env

Note: These commands are for Mac/Linux users only. Windows users should type these commands in git bash

Now open the dev.env file and add GOOGLE_CLIENT_ID=value from google apis, GOOGLE_CLIENT_SECRET=value from google apis

6. Run 'dev' script

npm run dev

More information

if you want more information, then please read the one-time-code flow implementation

Contributing

Please help me with the documentation and improve the code. I'll appreciate that. For changes, please open an issue first to discuss what you would like to change.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].