Problem Statement - User Authorization

Build a REST API using ExpressJS and use a third-party authorization API like GitHub to allow users to log in to your application. OAuth is an efficient and simple way to get access to protected data from an external application. It is more secure than asking users to log in with passwords.

  • Create an Express server to service requests from clients​
  • Build an html page that will be called when a client request is made to the root path of the application​
  • Maintain all the static files in a separate folder​
  • Redirect the user to GitHub to provide login credentials​
  • Using the code from GitHub, get an access token​
  • Login to the Node.js application and write the token in the cookie​​

Instructions

  1. Download and unzip the boilerplate code.
  2. Run the command npm install to install the dependencies.
  3. Open the boilerplate code in VSCode to develop the solution.
  4. Write the logic in .js file present in src folder
  5. Do not modify the html and css files present in the static folder
  6. Create the server in the app.js file

Setup

  1. Register the application on Github under OAuth applications
  2. Update config.js with CLIENT ID and CLIENT SECRET generated by the Github application

Running the code

  • Execute the npm start command to start the application
  • Test the output on the browser

Testing the application

  • Run the test scripts available under src/test by giving npm run test command in the terminal to test locally.

  • Refactor the solution to ensure all test cases are passing.

  • Zip the solution code with the name same as assignment name.

  • Upload the zipped solution for submission.