1

我正在尝试使用 msal 节点(我正在使用此示例)并使用我返回的令牌在 xbox live 中与 Microsoft 进行身份验证,问题是当我尝试调用 xboxlive 时收到错误 400(错误请求)。

 await axios
        .post(
            "https://user.auth.xboxlive.com/user/authenticate",
            {
                Properties: {
                    AuthMethod: "RPS",
                    SiteName: "user.auth.xboxlive.com",
                    RpsTicket: token, // the token i get from msal
                },
                RelyingParty: "http://auth.xboxlive.com",
                TokenType: "JWT",
            },
            {
                headers: {
                    "Content-Type": "application/json",
                    Accept: "application/json",
                },
            }
        )
        .then((x) => console.log("success", x))
        .catch((e) => console.error("error", e));
4

1 回答 1

1

看来您需要预先d=添加到令牌,然后将其作为 RpsTicket 的值传递。这是基于xbox-webapi-node npm 模块

await axios.post(
   "https://user.auth.xboxlive.com/user/authenticate",
   {
       Properties: {
           AuthMethod: "RPS",
           SiteName: "user.auth.xboxlive.com",
           RpsTicket: "d=" + token, // the token
       },
       RelyingParty: "http://auth.xboxlive.com",
       TokenType: "JWT",
    },
    {
        headers: {
            "Content-Type": "application/json",
            Accept: "application/json",
        },
     }
)
.then((x) => console.log("success", x))
.catch((e) => console.error("error", e));
于 2021-06-18T11:49:05.163 回答