openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #10363
Using Nova APIs from Javascript: possible?
Hi,
I've been playing with the Nova APIs from Javascript, and I've run into a
problem.
The very first thing one needs to do to use the APIs is to get a token.
That requires a POST to the API endpoint. Using curl & trystack that looks
like this:
$ curl -k -X 'POST' -v https://nova-api.trystack.org:5443/v2.0/tokens -d
'{"auth":{"passwordCredentials":{"username": "<username>",
"password":"<password>"}}}' -H 'Content-type: application/json'
The Javascript equivalent (using JQuery) is:
$.ajax({
url: "https://nova-api.trystack.org:5443/v2.0/tokens",
type: 'POST',
headers: {"Content-Type": "application/json"},
data: {"auth":{"passwordCredentials":{"username":"<username>",
"password":"<password>"}}},
success: function(data) { alert(data); }
});
That fails because the call is cross-domain, and Nova doesn't support CORS (
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing). <script> based
cross-domain requests only supports GET requests, so that doesn't work
either.
I have raised a bug: https://bugs.launchpad.net/nova/+bug/987044, but I'm
really hoping someone can point out something obvious I'm missing here.
Regards
Nick Lothian
Follow ups