React Express Authentication
Implement authentication in a React and Express app using JWT, integrate Google OAuth2, and manage state with Redux Toolkit.
Stack
- Year
- 2022
React Express Authentication
This is a simple authentication with ReactJS and ExpressJS. This project is using JWT for authentication (Access Token and Refresh Token) and OAuth2 with Google for authorization. This project is also using Redux Toolkit for state management.
Using the new Google Identity Services for Web (GSI) for authentication.
Live demo : Not available yet.
Source code : GitHub
Features
- Authentication with Google OAuth2
Tech Stack
Prerequisites
Installation and Usage
Clone the repository
git clone https://github.com/raprmdn/react-express-auth.gitcd to the project directory
cd react-express-authcd into the client directory & express directory
cd clientcd expressInstall dependencies for client & express
npm installCopy .env.example to .env for both client & express
cp .env.example .envConfigure the .env file for both client & express
Get the Google Client ID and Google Client Secret from Google Cloud Platform. Then, paste to the following environment variable in the .env file.
# client
REACT_APP_GOOGLE_CLIENT_ID=
REACT_APP_SERVER_URL=http://localhost:5000# express
NODE_ENV=
PORT=5000
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_HOST=
DB_DIALECT=
ACCESS_TOKEN_SECRET_KEY=
REFRESH_TOKEN_SECRET_KEY=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=http://localhost:5000/api/auth/login/googleCreate a database
sequelize db:createRun the migration
sequelize db:migrateRun the client & express
# client
npm start
# express
npm run devScreenshots


