The Drupal REST services is an user-created module for Drupal 7 and 6.
The module converts resources on Drupal sites - content types - into REST, XMLRPC, JSON, JSON-RPC, SOAP, AMF and other types for easy parsing by external applications.
It can also enable Drupal sites to accept CRUD operations to modify resources.
The requests between Drupal and external applications can have authentications via OAuth.
- Install Services module 7.x-3.3 - http://drupal.org/project/services
- Install Services Views module 7.x-1.0-beta2 - http://drupal.org/project/services_views
- Enable both modules and the REST server module.
- Install OAuth 7.x-3.0+18-dev - http://drupal.org/project/oauth (You must use this version because the recommended version - 7.x-3.0 - is bugged)
The Libraries module must be at least version 7.x-2.0 for REST server.
This is a two-stage process.
First, make a Service Endpoint that hosts REST resources; it is seen as the first part of the URL to your resource.
Next, make a REST resource, which is a View customized by the Services View module; in it, you specify which Content Types are included.
Authentication is configured afterwards.
Config Endpoint / View without OAuthRead more
Testing a three-legged and two-legged OAuth REST, using Services 7.x-3.2 and Oauth 7.x-3.0, with PHP Client
Here I will post all my system settings and configurations to test it out.
- CentOS 6.3
- PHP 5.3.18
- PECL Oauth extension (via command pecl install oauth)
- Server URL: http://core.zeus.lan (you can use any URL BUT You SHOULD really going for HTTPS)
- Client URL: http://localhost/oauth.php (this will be used below)
I use location sites/all/modules/contrib for my drupal modules.
First we set up the services with oauth.
- In Drupal site, install modules: REST Server, OAuth Authentication, OAuth Provider UI.
- In Drupal directory, comment out line 6 to 8 in file oauth/lib/OAuth.php, since it will conflict with PECL OAuth.
- In Drupal site, Create OAuth context in admin/config/services/oauth/add, make sure to create Authorization level and set as default.
After a couple of days bashing my head against my desk, I have finally got a C client to talk to Drupal 7.x using Services 3.x (XMLRPC) and OAuth authentication. Previously I had been using Drupal 6.x with Services 2.x and an API key, but the API key option is not available in Services 3.x. I looked for documentation explaining how to set up Services 3.x with OAuth, but I couldn't find a step-by-step tutorial. When I finally worked it out, I decided I'd better write one so that others don't have to follow my path of pain.
Please leave any comments/questions below.