External Login Drupal

In Drupal 7, i need to implement an external login process.

I have defined an api which takes input as username & password and returns the json result.


Need to use above API for drupal login in below cases,

  1. Need to check it is drupal administrator credentials
  2. If yes, login with existing database.
  3. If not, call API and pass the user details to it.
  4. After successful, need to create a session for that user.

For Registration:

  1. Call the API,


pass the details such as name, email, password, like so. After successful create an session for the user.

This is my requirement, and i looked out for any contributed modules. Nothing in the bag matches my requirement.

I wish, i could get any help to achieve this.

Actually am new to this platform, any links will be very much appreciated.

Drupal version: 

Source: https://www.drupal.org/taxonomy/term/2/feed