External login , in case internal login fail
You can use:

drupal_external_login_register


  Helper function for authentication modules. Either logs in or
  registers the current user


An example implementation is detailed here:

https://api.drupal.org/comment/13434#comment-13434