Skip to content

Instantly share code, notes, and snippets.

@shalvah
Last active October 23, 2018 14:42
Show Gist options
  • Save shalvah/920d1d8282ee18e515c412024f474ddc to your computer and use it in GitHub Desktop.
Save shalvah/920d1d8282ee18e515c412024f474ddc to your computer and use it in GitHub Desktop.

Why use this?

Supposing you're building an app (for instance, a voting app), and you want to restrict it to UNN students. Simply ask them to login with their UNN Portal details, and pass them to this API to verify their identity. (Please do not store those credentials 🙏).

How to Use

There's only one endpoint: https://unn-api.herokuapp.com/students/auth

Make a POST request with the following parameters (form-data or application/json content types acceptable)

  • username: The student s unnportal.unn.edu.ng username. Example: 2013/123456
  • password: The student s unnportal.unn.edu.ng password

If the login was successful, you should get a response like this (note the capitalization):

{
  "status": "success",
  "data": {
      "surname": "ADEBAYO",
      "first_name": "SHALVAH",
      "middle_name": "",
      "sex": "Male",
      "mobile": "080xxxxxxxx",
      "email": "[email protected]",
      "department": "ELECTRONIC ENGINEERING",
      "level": "200 LEVEL",
      "entry_year": "2010-2011",
      "grad_year": "2019-2020",
      "matric_no": "201x/xxxxxx",
      "jamb_no": "xxxxxxxxxx"
  }
}

For a failed login, you should get a response like this:

{
    "status": "error",
    "message": "Login failed. Please check your credentials and try again."
}

Note: for this API to work, it has to make 3 web requests to the UNN portal. To optimize repeat requests, the API caches student details for a period of 4 hours. This means if you are able to login successfully, subsequent API calls will load your details from cache. You can explicitly force it to re-authenticate by sending a Cache-Control: no-cache header

Packages

Building a PHP app? Instead of making requests manually, you could use this package. Makes working with this API a breeze!

(PS. feel free to build packages for other languages, and holla at me to list them here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment