In this series of articles we will be creating a basic Github OAuth application using Express.js. We'll also use Passport.js as our authentication middleware.
We will be using mongoDB, mongoose for the database and also use session storage for this application.
To setup our app we need to follow the following steps -
- install node, npm, mongoDB, express, express generator if not installed.
- create a project folder and in your project folder use the express generator to initialise our application.
- while creating the express application make sure we have installed the following dependencies these will be available in
package.json
-
- express
- passport
- passport-github
- express-session
- dotenv
- connect-mongo
- debug
- ejs (or any templating engine)
- mongoose
- http-errors
- morgan
We will setup our ejs templates first -
In the views folder we will create our templates since this will be only a backend application.
we will just add a link that points to our OAuth route for now, you can create these to your liking later. You can also create success, failure views, etc.
The folder structure after we complete our app will look like this for reference -
Creating the application
There are 5 steps in which we will be creating our Github OAuth application -
- Register Application.
- Handle Routes.
- Create Strategy for Github OAuth.
- Adding copy of user data in our local database.
- Serialize & deserialise.
Top comments (0)