Senither / hypixel-discord-chat-bridge

A two-way chat bridge between Hypixel guild chat and Discord.
MIT License
29 stars 118 forks source link

Error when using a Microsoft Account #3

Closed itsneyoa closed 3 years ago

itsneyoa commented 3 years ago

Hi, I'm trying to setup a bridge bot using an alt for my guild, however the alt is a microsoft account rather than a mojang account. In MinecraftManager.js I've changed auth: 'mojang' to auth: 'microsoft' as below/

createBotConnection() {
    return mineflayer.createBot({
      host: config.server.host,
      port: config.server.port,
      username: config.minecraft.username,
      password: config.minecraft.password,
      version: false,
      auth: 'microsoft',
    })
  }

The error this gives is

\hypixel-discord-chat-bridge-master\node_modules\minecraft-protocol\src\client\microsoftAuth.js:27
      if (err.details) throw new Error(`Unable to authenticate with Xbox Live: ${JSON.stringify(err.details)}`)
                             ^

Error: Unable to authenticate with Xbox Live: {"statusCode":401,"reason":"UNAUTHORIZED"}
    at \hypixel-discord-chat-bridge-master\node_modules\minecraft-protocol\src\client\microsoftAuth.js:27:30
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async module.exports (\hypixel-discord-chat-bridge-master\node_modules\minecraft-protocol\src\client\microsoftAuth.js:25:25)

I've tested with my main (mojang) account and it works perfectly, but I'd rather not use that for a chat bridge. Any help you could give would be greatly appreciated, thanks in advance :)

Senither commented 3 years ago

Hi itsneyoa,

From reading through PrismarineJS/mineflayer#1549 and PrismarineJS/mineflayer#1577 the issue is most likely related to Mineflayer being out of date, I've gone ahead and updated the app to use the latest version of Mineflayer in the fcdc7b4 commit, so hopefully, all you'd need to do is update the app with a git pull to get the changes, and run yarn install to get the new versions of the dependencies. I don't personally own a Microsoft Minecraft account so I can't actually test if this fixes your issue, however, let me know if it works out for you. 👍

itsneyoa commented 3 years ago

Hi,

Updating mineflayer prompted you to login with your microsoft account when running node index.js for the first time, however after that I get this chaos:

Discord client ready, logged in as Trouble Bridge#4465
Unable to authenticate with Microsoft XboxReplayError: Request failed with status code 401
    at Object.internal (~\Hypixel-Bridge\node_modules\@xboxreplay\errors\dist\index.js:33:77)
    at ~\Hypixel-Bridge\node_modules\@xboxreplay\xboxlive-auth\dist\core\xboxlive\index.js:79:32
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Object.authenticatePassword (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\microsoftAuth.js:70:21) {
  __XboxReplay__: true,
  details: { statusCode: 500, reason: 'INTERNAL_SERVER_ERROR' }
}
Retrying auth with device code flow
XboxReplayError: Request failed with status code 401
    at Object.internal (~\Hypixel-Bridge\node_modules\@xboxreplay\errors\dist\index.js:33:77)
    at ~\Hypixel-Bridge\node_modules\@xboxreplay\xboxlive-auth\dist\core\xboxlive\index.js:79:32
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async XboxTokenManager.getXSTSToken (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\tokens.js:216:18)
    at async retry.msa.forceRefresh (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:105:22)
    at async retry (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:26:14)
    at async MsAuthFlow.getXboxToken (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:102:14)
    at async retry.xbl.forceRefresh (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:118:22)
    at async retry (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:26:14)
    at async MsAuthFlow.getMinecraftToken (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:117:14) {
  __XboxReplay__: true,
  details: { statusCode: 500, reason: 'INTERNAL_SERVER_ERROR' }
}
Minecraft Bot Error:  XboxReplayError: Request failed with status code 401
    at Object.internal (~\Hypixel-Bridge\node_modules\@xboxreplay\errors\dist\index.js:33:77)
    at ~\Hypixel-Bridge\node_modules\@xboxreplay\xboxlive-auth\dist\core\xboxlive\index.js:79:32
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async XboxTokenManager.getXSTSToken (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\tokens.js:216:18)
    at async retry.msa.forceRefresh (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:105:22)
    at async retry (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:26:14)
    at async MsAuthFlow.getXboxToken (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:102:14)
    at async retry.xbl.forceRefresh (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:118:22)
    at async retry (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:26:14)
    at async MsAuthFlow.getMinecraftToken (~\Hypixel-Bridge\node_modules\minecraft-protocol\src\client\authFlow.js:117:14) {
  __XboxReplay__: true,
  details: { statusCode: 500, reason: 'INTERNAL_SERVER_ERROR' }

I've tried npm update to see its any of the other packages which out out of date with no luck so far Thanks :) - ney

Senither commented 3 years ago

From the looks of the error message, you're getting a 401 response code which is an unauthorized request, it most likely means your login details don't match up with what your actual account uses. There is also a 500 response code in the error message tho, which an internal server error, so it could also just be an issue with logging in using a Microsoft account.

itsneyoa commented 3 years ago

Turns out its an issue with the Microsoft account being type 'child' (<18), so changing the age on the account to anything over 18 works!