3

I've been playing around with Service module, which it seem the best module for exposing web service specificaly I have REST architecture. Nevertheless haven't been able to clear how does the authentication and authorization works here.

I know than I can expose a specific method like this:

/**
 * Implementation of hook_service()
 */
function custom_service_services_resources() {
...

 return array(
    'volunteer'=>array(
    'actions'=>  'disable'=>array(
        'callback'=> '_custom_service_disable',
        'file' => array('type' => 'inc', 'module' => 'custom_service', 'name' => 'inc/custom_service'),
        'args'=> array(
            array(
                'name' => 'id_entity',
                'type' => 'string',
                'description' => 'The ID of the record',
                'source' => 'data',
                'optional' => FALSE,
              )
        ),
      'help' => t('Service custom for example.'),
    ) ),  

 ); }

And it work quite nicely but only with the admin user, I understand there are some extra access parameters like:

'access callback' => '_custom_service_access',
'access arguments' => array('disable'),
'access arguments append' => TRUE,

But they are not well documented, does anybody has an insight on how to use them in service module, thanks.

Aditional Information

Drupal Version: 7

Service Module

Edit

Apreciate the answer but the hook about the auth can be found in

http://www.ibm.com/developerworks/opensource/library/os-drupal-web-service-project/index.html

The problem with this example are:

  • The service access function (_note_service_access) will always return TRUE. That means that all calls are authenticated.

  • Why do they do

    $access = user_access('note service delete any note'); $access = $access || $note->uid == $user->uid &&

If they are not going to use it.

One last fact If I don't use the admin user with the services I can't get authorization.

  • 1
    What version of Drupal and services module are you using ? – Dinesh Kumar Sarangapani Sep 20 '12 at 4:56
  • Using the latest version of the module and drupal 7 – Necronet Sep 24 '12 at 9:11

Your Answer

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

Browse other questions tagged or ask your own question.