To the master of ceremonies in charge of Spark’s api server security protocols,
Not sure if this would really help in any sorely needed way, since all GET requests to the API server are https encapsulated. However, those URIs do get logged in plain text on the server, so an argument of extreme paranoidal proportions might be made in favor of avoiding tokens in the URI. Thus, I besiege thee …
For ajax Sparkcore variable access via a web app, I was trying to get the ?access_token=
thing out of the GET/URL and into an, Authorization: Bearer ...
header. But it turns out the api.spark.io
server CORS responses do not permit the Authorization header. Following is the related response from the server, to my browser’s OPTIONS request …
Access-Control-Allow-Headers X-Requested-With, Content-Type, Accept
If the api server god (homage !) would be willing to append Authorization
to that response, then it would enable keeping the access_token out of the GET URL, such that the following jQuery ajax variable GET request would work …
var url = baseURL + coreID + "/variableget"; // + "?access_token=" + accessToken;
$.ajax({
url: url,
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
},
dataType: "json",
success: function(obj) {
console.log(obj);
},
fail: function(obj) {
console.log(obj);
}
});
Just a thought.
Interestingly, the same sort of thing already works, using curl
…
curl -H "Authorization: Bearer e4ff9...4f316c" https://api.spark.io/v1/devices/testdevice/variableget
… apparently because curl doesn’t care to honor CORS rules (probably doesn’t even send an OPTIONS pre-flight request) and the api server just gives in and serves the request anyhow. Rather bizarre that last part, I thought. {shrug}