I am trying to register and log in users via the Services module 7.0-3.11 on Drupal 7.36.

The endpoints are declared from the following code.

$endpoint = new stdClass();
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'user_service';
$endpoint->server = 'rest_server';
$endpoint->path = 'user_api';
$endpoint->authentication = array(
  'services' => 'services',
$endpoint->server_settings = array(
  'formatters' => array(
    'json' => TRUE,
    'bencode' => FALSE,
    'jsonp' => FALSE,
    'php' => FALSE,
    'xml' => FALSE,
  'parsers' => array(
    'application/json' => TRUE,
    'application/vnd.php.serialized' => FALSE,
    'application/x-www-form-urlencoded' => FALSE,
    'application/xml' => FALSE,
    'multipart/form-data' => FALSE,
    'text/xml' => FALSE,
$endpoint->resources = array(
  'user' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => '1',
      'index' => array(
        'enabled' => '1',
    'actions' => array(
      'login' => array(
        'enabled' => '1',
      'logout' => array(
        'enabled' => '1',
      'token' => array(
        'enabled' => '1',
      'request_new_password' => array(
        'enabled' => '1',
      'register' => array(
        'enabled' => '1',
    'targeted_actions' => array(
      'password_reset' => array(
        'enabled' => '1',
$endpoint->debug = 1;

I am using basic PHP code for the testing purpose. Please have a look at the GIST.

The problem is that, while I run the test page, I can see it registers a new user and outputs the following.

stdClass Object
    [uid] => 14
    [uri] => http://vote-app.dd:8083/user_api/user/14

But while I try to log in with the same user (as per the code) it outputs the following error.

["Wrong username or password."]

I need some help on this. Am I missing something?

I also checked https://www.drupal.org/node/1491754 and other Drupal pages for this too.

1 Answer 1


Found the solution. Just for future references for others and me as well :-)

There is an issue in Services module Wrong username and password, just after a creation of a user where someone faced the same problem. User login just registration. So as it stated,

If you are anonymous user and register a user your register form does not have password field at all. It has only username and email fields. All instructions are sent by email (with token to log in and set the password). So register call actually does not set the password.

This is actually true. If I go to the admin and change the password again then it's working. So the solution is to alter two variables,

variable_set('user_email_verification', FALSE);
variable_set('user_register', TRUE);

This will now allow the users to register by themselves.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.