PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.92k stars 904 forks source link

Microsoft Auth #3365

Closed faketraffic closed 4 months ago

faketraffic commented 5 months ago

Is your feature request related to a problem? Please describe.

when an Microsoft Account that has security info pending it wont login in

Describe the solution you'd like

just by adding a check if it has and then still logging in

extremeheat commented 5 months ago

Update your dependencies with npm update and try again, otherwise provide your code and the exact error message you get when using the readme echo example:

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
  host: 'localhost', // minecraft server ip
  username: 'username',
  auth: 'microsoft'
})

bot.on('chat', (username, message) => {
  if (username === bot.username) return
  bot.chat(message)
})

// Log errors and kick reasons:
bot.on('kicked', console.log)
bot.on('error', console.log)
faketraffic commented 4 months ago

const mineflayer = require('mineflayer'); const fs = require('fs');

function readAltsFromFile() { try { const data = fs.readFileSync('alts.txt', 'utf-8'); return data.split('\n').map(line => { const [email, password] = line.split(':'); return { email, password }; }); } catch (error) { console.error('Error:', error.message); return []; } }

function createBot(email, password) { const bot = mineflayer.createBot({ username: email, password: password, auth: 'microsoft', host: 'hypixel.net', port: 25565, version: '1.8.9' });

bot.on('spawn', () => { console.log(${email}:${password} is unbanned); bot.quit(); setTimeout(startNextBot, 1000); });

bot.on('kicked', (reason) => { console.log(${email}:${password} is banned); setTimeout(startNextBot, 1000); });

bot.on('error', err => { console.error(Error for ${email}:${password}: ${err.message}); bot.quit(); setTimeout(startNextBot, 1000); }); }

let alts = readAltsFromFile(); let currentIndex = 0;

function startNextBot() { if (currentIndex < alts.length) { const { email, password } = alts[currentIndex]; currentIndex++; createBot(email, password); } else { console.log('No more accounts to try.'); } }

startNextBot();

and my error is "Error for adrianalondu@hotmail.com:Olimpia5.0 : Invalid credentials. Sign in failed, try removing the password field

XboxReplayError: Invalid credentials. at Object.unauthorized (c:\Users\tharm\Desktop\Ban checker\node_modules\@xboxreplay\errors\dist\index.js:25:74) at c:\Users\tharm\Desktop\Ban checker\node_modules\@xboxreplay\xboxlive-auth\dist\core\live\index.js:71:32 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async XboxTokenManager.doReplayAuth (c:\Users\tharm\Desktop\Ban checker\node_modules\prismarine-auth\src\TokenManagers\XboxTokenManager.js:127:31) at async MicrosoftAuthFlow.getXboxToken (c:\Users\tharm\Desktop\Ban checker\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:132:20) at async retry.xbl.forceRefresh (c:\Users\tharm\Desktop\Ban checker\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:167:22) at async retry (c:\Users\tharm\Desktop\Ban checker\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:24:14) at async MicrosoftAuthFlow.getMinecraftJavaToken (c:\Users\tharm\Desktop\Ban checker\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:166:7) at async Object.authenticate (c:\Users\tharm\Desktop\Ban checker\node_modules\minecraft-protocol\src\client\microsoftAuth.js:22:58) { XboxReplay: true, details: { statusCode: 401, reason: 'UNAUTHORIZED' } }" and that onlys happens with accs with security info pending

extremeheat commented 4 months ago

Remove the password field and it should work