Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/souravpl8092/facebook-auth
Facebook Authentication using Node.js, Express, and Mongoose
https://github.com/souravpl8092/facebook-auth
bootstrap dotenv ejs express-sessions expressjs mongodb moongose nodejs passport passport-facebook
Last synced: 19 days ago
JSON representation
Facebook Authentication using Node.js, Express, and Mongoose
- Host: GitHub
- URL: https://github.com/souravpl8092/facebook-auth
- Owner: souravpl8092
- Created: 2023-04-22T05:02:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-23T18:16:15.000Z (over 1 year ago)
- Last Synced: 2024-05-28T22:46:41.927Z (8 months ago)
- Topics: bootstrap, dotenv, ejs, express-sessions, expressjs, mongodb, moongose, nodejs, passport, passport-facebook
- Language: JavaScript
- Homepage: https://plum-nice-lamb.cyclic.app/
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readMe.md
Awesome Lists containing this project
README
Facebook Authentication using Node.js, Express, and Mongoose
Before Login
After Login
Overview
### This code implements a Facebook authentication system using Node.js, Express, Passport.js and Mongoose.
Requirements
- Node.js
- npm or yarn
- MongoDB instance
- Facebook App credentials
## Installation
### 1. Clone the repository and install the dependencies:
- git clone https://github.com/souravpl8092/QuestLabs-Assignment.git
- cd QuestLabs-Assignment
- npm install
2. Create a .env file in the root directory of the project and add the following variables:
- SESSION_SECRET = [ your session secret ]
- FACEBOOK_CLIENT_ID = [ your facebook app client ID ]
- FACEBOOK_SECRET_KEY = [ your facebook app secret key ]
- FACEBOOK_CALLBACK_URL = [ your facebook app callback URL ]
- mongoURL = [ your mongodb URL ]
- PORT = [ port number to run the server ]
3. Start the server:
- npm start
## Code Explanation
### config/db.js
- This file connects to the MongoDB server using the mongoose library.
### models/User.model.js
- This file defines a User schema using the mongoose.Schema method.
### routes/facebook-auth.js
- This file defines a facebook-auth router using the express.Router method and implements the Facebook authentication strategy using the passport-facebook library.
### server.js
- This file initializes the Express application, sets up the session middleware, passport.js authentication, and defines the routes for the Facebook authentication.
Thank You