This is related to a bug report I filed just moments ago. If there's someone who has successfully used the REST server in the Services module with JSONP requests (cross-domain), I'd be happy to hear about it.
I'm currently trying to get cross-domain JSONP requests in services working. However, it seems that I'm out of luck. I have created a sandbox Drupal installation with just the service (and dependent) modules installed. The endpoint for testing is setup as follows:
- name:
api
- server:
REST
- debug:
disabled
- authentication:
session
The REST server is setup as follows:
- response formatters:
json
,jsonp
- request parsing:
application/json
,application/x-www-form-urlencoded
,multipart/form-data
All resources provided by default are turned on. What I'm trying to achieve now is to get the user logged in, in order to be able to access other, permission based ressources such as node etc.
The test request is as follows:
- url and params:
http://d7.sandbox/api/user/login.json?callback=test&username=test&password=test
- http header
Content-Type: application/json
The response returns a 401 HTTP header and the following message:
401 (Unauthorized: Access denied for user anonymous)
It seems that this is not the desired behavior. JSON requests (e.g. a POST request to api/user/login.json
) work fine. However, these cannot be used for applications running on other domains or devices to retrieve data from Drupal over the REST server.
Any ideas?
P.S. I went through the tests in the services package. It seems that tests for the JSONP functionality are missing as well.