Details
Details
I'm try connect to Phabricator Conduit API with pure javascript, no succcess.
The code sample is:
var _TOKEN = (new Date().getTime() / 1000 + ""); var connect_params: ({ "host": _PHAB, "user": _USER, "authToken": _TOKEN, "clientVersion": 1.0, "client": "phabricator-client", "authSignature": hash.sha1(_TOKEN + _CERT), }); post("/api/conduit.connect", formData, requestCallback); function post(requestPath, dataToSend, callback) { var xhr = new XMLHttpRequest(); xhr.open(requestType, phabricatorUrl + requestPath, true); xhr.onreadystatechange = function() { if (xhr.readyState === XMLHttpRequest.DONE) callback(JSON.parse(xhr.responseText), parseInt(xhr.status)); } } xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("Content-Length", parseInt(dataToSend)); xhr.send(dataToSend);
I get the result as json:
{"result":null,"error_code":"ERR-INVALID-CERTIFICATE","error_info":"Your authentication certificate for this server is invalid."}