Pierce01 / MinecraftLauncher-core

Lightweight module that downloads and runs Minecraft using javascript / NodeJS
MIT License
356 stars 81 forks source link

Problem forbidden launch. #98

Closed AnonymeUSB closed 1 year ago

AnonymeUSB commented 1 year ago

Hello,

I have a project to create a launcher with electron.js, using minecraft-launcher-core. Only, I get this error message here:

[MCLC]: Version parsed from the version manifest
C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\Node_modules\minecraft-launcher-core\components\authenticator.js:39
        return reject(new Error('Validation error: ' + response.statusMessage))
                      ^

Error : Validation error : Forbidden
    at Request._callback (C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\node_modules\minecraft-launcher-corecomponents\authenticator.js:39:23)
    at Request.self.callback (C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\node_modules\request.js:185:22)
    at Request.emit (node:events:513:28)
    at Request.<anonymous> (C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\node_modules\request.js:1154:10)
    at Request.emit (node:events:513:28)
    at IncomingMessage.<anonymous> (C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\Node_modules\request.js:1076:12)
    at Object.onceWrapper (node:events:627:28)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

My code:

const { Client, Authenticator } = require('minecraft-launcher-core') ;
const launcher = new Client() ;

let opts = {
    clientPackage : null,
    // For production launchers, I recommend not passing 
    // the getAuth function through the authorization field and instead
    // handle the authentication externally before initializing
    // MCLC in order to handle errors and validation based on authentication!
    authorization : Authenticator.getAuth("allyssisation@gmail.com", "password"),
    root : "./minecraft",
    version : {
        number : "1.19",
        type: "release"
    },
    memory: {
        max : "6G",
        min : "4G"
    }
}

launcher.launch(opts);

launcher.on('debug', (e) => console.log(e)) ;
launcher.on('data', (e) => console.log(e)) ;

I don't have a minecraft account, and I would have liked that the users of the platform didn't have to create one. Example: NationsGlory. I take this opportunity to ask if it is possible to launch my server directly rather than the whole game.

Bricklou commented 1 year ago

Just don't add the password parameter. And you should handle properly the Authenticator in case you get errors.

AnonymeUSB commented 1 year ago

Hello, I removed the password, it works better now, but when I launch it, a terminal opens then closes very quickly, then nothing. Outpout :

[MCLC]: Using Java version 18.0.2.1 64-bit
[MCLC]: Parsed version from version manifest
[MCLC]: Collected class paths
[MCLC]: Using ; to separate class paths
[MCLC]: Attempting to download assets
[MCLC]: Downloaded assets
[MCLC]: Set launch options
[MCLC]: Launching with arguments -XX:-UseAdaptiveSizePolicy -XX:-OmitStackTraceInFastThrow -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true -Djava.library.path=C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft -Xmx6G -Xms4G -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -cp C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\logging\1.0.0\logging-1.0.0.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\blocklist\1.0.10\blocklist-1.0.10.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\patchy\2.2.10\patchy-2.2.10.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\github\oshi\oshi-core\5.8.5\oshi-core-5.8.5.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\net\java\dev\jna\jna\5.10.0\jna-5.10.0.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\net\java\dev\jna\jna-platform\5.10.0\jna-platform-5.10.0.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\slf4j\slf4j-api\1.8.0-beta4\slf4j-api-1.8.0-beta4.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\apache\logging\log4j\log4j-slf4j18-impl\2.17.0\log4j-slf4j18-impl-2.17.0.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\ibm\icu\icu4j\70.1\icu4j-70.1.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\javabridge\1.2.24\javabridge-1.2.24.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\net\sf\jopt-simple\jopt-simple\5.0.4\jopt-simple-5.0.4.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-common\4.1.77.Final\netty-common-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-buffer\4.1.77.Final\netty-buffer-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-codec\4.1.77.Final\netty-codec-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-handler\4.1.77.Final\netty-handler-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-resolver\4.1.77.Final\netty-resolver-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-transport\4.1.77.Final\netty-transport-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-transport-native-unix-common\4.1.77.Final\netty-transport-native-unix-common-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\io\netty\netty-transport-classes-epoll\4.1.77.Final\netty-transport-classes-epoll-4.1.77.Final.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\google\guava\guava\31.0.1-jre\guava-31.0.1-jre.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\brigadier\1.0.18\brigadier-1.0.18.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\datafixerupper\5.0.28\datafixerupper-5.0.28.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\google\code\gson\gson\2.8.9\gson-2.8.9.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\authlib\3.5.41\authlib-3.5.41.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;C:\Users\User\Dauncher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-glfw\3.3.1\lwjgl-glfw-3.3.1-natives-windows-x86.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-stb\3.3.1\lwjgl-stb-3.3.1.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-stb\3.3.1\lwjgl-stb-3.3.1-natives-windows.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-stb\3.3.1\lwjgl-stb-3.3.1-natives-windows-x86.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-tinyfd\3.3.1\lwjgl-tinyfd-3.3.1.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-tinyfd\3.3.1\lwjgl-tinyfd-3.3.1-natives-windows.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\org\lwjgl\lwjgl-tinyfd\3.3.1\lwjgl-tinyfd-3.3.1-natives-windows-x86.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\text2speech\1.13.9\text2speech-1.13.9.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\libraries\com\mojang\text2speech\1.13.9\text2speech-1.13.9-natives-windows.jar;C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\versions\1.19\1.19.jar net.minecraft.client.main.Main --username allyssisation@gmail.com --version 1.19 --gameDir C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft --assetsDir C:\Users\User\Documents\EarthAwakening\Launcher\EarthAwakening\minecraft\assets --assetIndex 1.19 --uuid 039adb14-a150-39d2-9521-4ca85d2bae95 --accessToken 039adb14-a150-39d2-9521-4ca85d2bae95 --clientId 039adb14-a150-39d2-9521-4ca85d2bae95 --xuid 039adb14-a150-39d2-9521-4ca85d2bae95 --userType mojang --versionType release

Code :

const { Client, Authenticator } = require('minecraft-launcher-core');
const launcher = new Client();

let opts = {
    clientPackage: null,
    // For production launchers, I recommend not passing 
    // the getAuth function through the authorization field and instead
    // handling authentication outside before you initialize
    // MCLC so you can handle auth based errors and validation!
    authorization: Authenticator.getAuth("allyssisation@gmail.com"),
    root: "./minecraft",
    version: {
        number: "1.19",
        type: "release"
    },
    memory: {
        max: "6G",
        min: "4G"
    }
}

launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));
AnonymeUSB commented 1 year ago

The problem seems to be the version, because when I change "1.19" to "1.16", it works. But all my mods are running on 1.19, so I don't have the choice of version.