我需要向https://authserver.mojang.com/authenticate发送请求
并获得响应
{
"accessToken": "valid accessToken",
"clientToken": "client identifier",
"selectedProfile": {
"id": "profile identifier",
"name": "player name"
},
"requestUser": true
}
但是我不知道如何向服务器索要输出。
我需要输入的是
{
"agent": { "name": "Minecraft", "version": 1 },
"username": "-email here-",
"password": "-pass here-"
}
这是获取令牌所需的数据,但我似乎无法获得代码来向服务器请求令牌数据,然后接收它并将其放入JSON中。
发布于 2020-05-31 07:24:34
const postData = async _ => {
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"agent": { "name": "Minecraft", "version": 1 },
"username": "-email here-",
"password": "-pass here-"
})
})
console.log(response)
}
这应该会得到你需要的响应,通过https://wiki.vg/Authentication#Payload这个链接来判断。
https://stackoverflow.com/questions/62109637
复制相似问题