使用参数发送凭据 - PUT -Firefox
Sending credentials with params - PUT -Firefox
我登录了沃尔玛的网站,我有一个购物车。当我将商品添加到购物车时,我发出 PUT
请求
PUT 请求图片 - https://i.imgur.com/f9lWqbC.png
就这样,我将一件商品添加到我的购物车。
现在,进入正题post。我正在为 Firefox 编写一个扩展,主要是 content_script
。脚本的主要功能是发出与单击沃尔玛页面上的 Add to cart
按钮相同的请求,但我不知道如何发送可在请求 Headers 中找到的所有凭据。
显然,我有权发送适当的请求,但这只能通过单击按钮来实现,我的目标是通过 content_script
(或后台脚本)使用我的扩展程序发送它。
content_script.js
(function(){
var params = {"cartItems":[{"offerId":"8E5AE39B44CD467DAC4AAA3A0042110F","quantity":3}]}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Typical action to be performed when the document is ready:
var res = JSON.parse(xhttp.responseText);
console.log(res);
}
};
xhttp.open("PUT", "https://grocery.walmart.com/api/v3/cart/:GCRT/items", true);
xhttp.withCredentials = true;
xhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhttp.send(JSON.stringify(params));
})();
如您所见,我将 xhttp.withCredentials
设置为 true
但这不起作用,因为我的控制台上没有任何内容。
正确的问题是:如何向沃尔玛证明此请求仍然来自我的 PC 和我的帐户?
尝试发送该图片中包含的更多 headers,但我仍然认为您不能发送 cookie
key-value 对,因为 XMLHttpRequest
中禁止发送.
我登录了沃尔玛的网站,我有一个购物车。当我将商品添加到购物车时,我发出 PUT
请求
PUT 请求图片 - https://i.imgur.com/f9lWqbC.png
就这样,我将一件商品添加到我的购物车。
现在,进入正题post。我正在为 Firefox 编写一个扩展,主要是 content_script
。脚本的主要功能是发出与单击沃尔玛页面上的 Add to cart
按钮相同的请求,但我不知道如何发送可在请求 Headers 中找到的所有凭据。
显然,我有权发送适当的请求,但这只能通过单击按钮来实现,我的目标是通过 content_script
(或后台脚本)使用我的扩展程序发送它。
content_script.js
(function(){
var params = {"cartItems":[{"offerId":"8E5AE39B44CD467DAC4AAA3A0042110F","quantity":3}]}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Typical action to be performed when the document is ready:
var res = JSON.parse(xhttp.responseText);
console.log(res);
}
};
xhttp.open("PUT", "https://grocery.walmart.com/api/v3/cart/:GCRT/items", true);
xhttp.withCredentials = true;
xhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhttp.send(JSON.stringify(params));
})();
如您所见,我将 xhttp.withCredentials
设置为 true
但这不起作用,因为我的控制台上没有任何内容。
正确的问题是:如何向沃尔玛证明此请求仍然来自我的 PC 和我的帐户?
尝试发送该图片中包含的更多 headers,但我仍然认为您不能发送 cookie
key-value 对,因为 XMLHttpRequest
中禁止发送.