1
この側面では新しいので、適切な構文が見つからないようです。 POST要求のペイロードでは、アクセスしようとしているサービスに応じて、「grant_type = client_credentials」を含める必要があります。しかし、リクエストペイロードにユーザー名とパスワードを含めるJavaScript構文は見つかりません。ここで私は(私は明白な理由のために私の鍵と秘密を削除した)これまで持っているものです:事前にXMLHTTPRequest不正なリクエスト(400)を返す - 「パラメータを要求する:grant_type」
var request = new XMLHttpRequest();
var path="https://ops.epo.org/3.1/auth/accesstoken";
request.onreadystatechange=state_change;
var encodedData = window.btoa(Key:Secret"); //encode consumer key and secret key
document.write(encodedData);
request.open("POST", path, true);
request.setRequestHeader("Authorization", encodedData);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send(null);
function state_change() {
if (request.readyState == "4") //Request finished and response is ready
{
if (request.status == "200") {
alert("Success");
}
else {
alert("Problem retrieving data");
console.log(this.responseXML);
}
}
}
おかげで、最後の数時間のために、この上で立ち往生されて。