Integrate external DB users via their API in Drupal 7 I want to integrate an external API (REST) to login users which are on that external database using the drupal 7 login form on my site.

I have the API specifications for Login, Registering, Getting member details and Check logged in. I also have a URL to test GET and POST requests on that external DB.

How do I integrate it with Drupal database so that users can log in using either Drupal's DB or external DB (integrated with the API)?

I have just discovered Services module but not sure if it is of any help.

I'm not an expert in creating custom modules either so any sample code or any pointers would really help here.

NOTE: External API requests return XML output
In order to implement external authentication you need to alter the login forms (user_login and user_login_block) to alter their validation handlers.

The default validation handlers for the forms are user_login_name_validate(), user_login_authenticate_validate() and user_login_final_validate(). You will need to replace user_login_authenticate_validate which is used to check the supplied username/password against local users table. Your replacement should invoke your API to handle the authentication.

Depending on your need, you may want to provide automatic registration (on the Drupal site) of new user on authentication. In such as case, you can use the user_external_login_register() function to create the account from your user_login_authenticate_validate replacement.

To map the Drupal user to the user on the external system, Drupal provides the user_get_authmaps() and user_set_authmaps() functions. Note that that user mapping mapping is automatically handled when using the user_external_login_register() and user_external_load() functions.

The perform your HTTP requests, you can use the drupal_http_request() function which usually do the job and support HTTPS. Of course, you can also use another HTTP library.

All of this will have to be done in a custom module and you will need good understanding of Drupal's Form API.

A comment on the documentation page for user_external_login_register() provides detailed explanation of the complete process.

Note: The Services module is useful when you need a read/write HTTP-based API for your Drupal site's data. In your case, it would not be usefull since you need to consume an existing API to authenticate the users.