xbox live 身份验证错误 400 错误请求

xboxlive authentication error 400 bad request

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

 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));

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

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));