我向通过自定义模块创建的Drupal端点发出PUT请求,并启用了基于HTTP的身份验证。当我使用授权头通过rest客户机调用api时,用户名和密码提示会一次又一次地出现,尽管我提供了一个有效的Drupal用户。我看到未经授权的用户错误,以及使用高级的rest客户端的铬。我该怎么解决呢?
这是我正在使用的代码。
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'),
),
);
}发布于 2017-03-27 08:36:51
apache服务器需要知道HTTP授权头,因此必须修改htaccess文件以接受HTTP授权头。
<IfModule mod_rewrite.c>
RewriteEngine on
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1https://drupal.stackexchange.com/questions/231943
复制相似问题