1

I have to match the following format when implementing Services to maintain some legacy APIs that were poorly written. I understand this is horrible practice and we're going to provide a new better OAUTH2 option going forward but that doesn't change my issue.

https://www.example.com/service/ServiceController.svc?username=YOUR_USERNAME&password=YOUR_PASSWORD&travelCode=TRAVEL_CODE

Short of writing my own authorization module that works with Services can anyone think of a method for getting this done using existing modules and Services.

I have tried Services Basic Authentication and Secure Services and either I am missing something or they don't do what I need.

Any help would be appreciated, I really don't want to customize something if I don't have to.

| improve this question | | | | |
  • why not rely on session authentication? – Mohammed Gomma Mar 8 '16 at 6:20
  • Because the calls are going to be made by an automated system on the other end, they need to make a single call like the structure above to get their API results. They will not have a session when making the call. – ttbakiatwoam Mar 8 '16 at 16:45
  • so you should implement one of the module hooks and authenticate the user in code besides check matching of travelcode – Mohammed Gomma Mar 8 '16 at 17:34
  • <sarcasm>Well thanks for that wonderful insight it was just the help I was looking for.</sarcasm> The Services module user authentication is done by implementing other modules for authentication and implementing an object variable with a call back to the user authentication function. In order to get the user name and password from the plain text url strings I am going to have to implement Retrieve arguments and right custom verification code. However, if someone else has already gone through this struggle I was hoping for advice or examples. – ttbakiatwoam Mar 10 '16 at 16:43
  • If some one faced he will surely advice you, BTW consider upvoting to be get high question rank. – Mohammed Gomma Mar 10 '16 at 19:17
0

By adding the following argument entries to my retrieve operation for my custom service I was able to achieve the desired effect.

                'args' => array(
                    array(
                        'name' => 'none',
                        'type' => 'string',
                        'description' => 'Function to perform',
                        'source' => array(
                            'path' => '0'
                        ),
                        'optional' => TRUE,
                        'default' => '0',
                    ),
                    array(
                        'name' => 'version',
                        'type' => 'int',
                        'description' => 'Function to perform',
                        'source' => array(
                            'param' => 'version'
                        ),
                        'optional' => TRUE,
                        'default' => '0',
                    ),
                    array(
                        'name' => 'username',
                        'type' => 'string',
                        'description' => 'Function to perform',
                        'source' => array(
                            'param' => 'username'
                        ),
                        'optional' => FALSE,
                        'default' => '0',
                    ),
                    array(
                        'name' => 'password',
                        'type' => 'string',
                        'description' => 'Function to perform',
                        'source' => array(
                            'param' => 'password'
                        ),
                        'optional' => FALSE,
                        'default' => '0',
                    ),
                    array(
                        'name' => 'id',
                        'type' => 'string',
                        'description' => 'Function to perform',
                        'source' => array(
                            'param' => 'id'
                        ),
                        'optional' => TRUE,
                        'default' => '0',
                    ),
| improve this answer | | | | |

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.