How to use OAuth with Express in NodeJS

Often in apps, we need to pull certain information from other services. Consider a scenario where you need to build a web application to assist hiring and recruitment. In such scenario, we often need to pull data from other sources like (Github, Linkedin, Stack Overflow etc). One of the best way to handle that transfer of information without compromising on the security is via OAuth.

The basic steps involved in Oauth are :-

Register an application for the service you intend to use within their website. In this example, we would be using Github as an example. Give an appropriate app name and provide the Authorization callback URL as http://localhost:3001/connect/github/callback . We will get back to this later.

. We will get back to this later. Users from your app are redirected to request their GitHub identity.

Users are redirected back to your site by GitHub with the access token.

Your app accesses the API with the user’s access token.

So, lets start building this in Node and the module we would be using for this is grant .