- Node v14.17
- Express v4.17
- MongoDB Atlas
- Mongoose v6
- Passport v0.4.1
This boilerplate project adds a "user" document to a "users" collection on MongoDB Atlas alongside creating a unique cookie than can be used for authentication. Passport's Google OAuth Strategy is used to handle interaction with Google's OAuth API. Cookie Session is used to store/retrive and encrypt data from a cookie.
- Create Google Develpper Project, get Google Client ID and Google Client Secret.
- Create MongoDB Atlas Project, get MongoURI and include password.
- Add the keys to the config/keys.js file as strings.
- npm install dependancies, npm run dev to start the development server
- localhost:5000/auth/google will route to Google OAuth Screen (unless already completed).
- localhost:5000/api/current_user will return a cookie object if the user has been authenticated correctly.
- localhost:5000/api/logout will log the user out.