You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
About
Facebook Authentication using Node.js, Express, and Mongoose