-1

I'm make a PUT request to a Drupal API end point created via a custom module and have enabled HTTP based authentication. When I call the api via rest client using Authorization header, the username and password prompts keeps coming again and again even though I supply a valid Drupal user. I see unauthorized user error as well using the advanced rest client on chrome. How do I solve it?

This is the code I am using.

function anonymize_user_services_resources() {
  return array(
    'update' => array(
      'update' => array(
        'help' => 'When user is deleted  users info should be anonymized',
        'callback' => 'anonymize_user_info',
       // 'access callback' => 'anonymize_callback',
        'access arguments' => array('update anonymize_user'),
        'access arguments append' => FALSE,
        'args' => array(
            array(
               'name' => 'id',
               'type' => 'int',
               'description' => 'The id of the user to update',
               'source' => array('path' => '0'),
               'optional' => FALSE,
            ),
          ),
        ),
      ),
    );

/**
* Implements hook_permission()
*/
function anonymize_user_permission() {
  return array(
    'update anonymize_user' => array(
      'title' => t('Update inactive user and anonymize'),
      'description' => t('Perform rest call to update and anonymize inactive user'),
    ),
  );
}
  • It would help if you could supply some relevant code. Did you enable basic_auth in your custom service? You can do so via REST UI module (drupal.org/project/restui). – mvdgun Mar 21 '17 at 22:56
0

The apache server needed to know the HTTP authorization header so the htaccess file had to be modified to accept the HTTP authorization header.

<IfModule mod_rewrite.c>
  RewriteEngine on

  SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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