Skip to content

Connection

adepierre edited this page Jun 11, 2023 · 3 revisions

Connection

Botcraft supports both servers in offline and online mode. If the server is in online mode, a valid Microsoft account (legacy Mojang accounts don't work anymore) owning the game is required. The connection is perfomed by the Connect function of the client. Botcraft uses a cache file to avoid asking credentials everytime. Please note that your credentials are never stored in files, only temporary access tokens and player chat certificates are.

Offline mode

If you know the server you want to connect to is in offline mode (i.e. accepting "cracked" clients), a minecraft account is not required. Any login can be used, and force_microsoft_account must be set to false (it is by default if omitted). In this case, there will be no connection made to authentication server, and no credentials are used.

Mojang account

Mojang accounts don't work anymore since March 10 2022 (see this article) and the corresponding connection functions have been removed in 0670a5bb.

To connect using a Mojang account, you'll need to use the connect function with your username (email or account name for very old accounts) and password, just like you use them in the official minecraft launcher. Before the connection to the server, Botcraft will try to get a minecraft token with these credentials by contacting the minecraft authentication server. This token will be cached in the botcraft_cached_credentials.json file, using the provided login as key. Multiple accounts with multiple login can thus be used, they'll all be cached in the same file.

If the cache file exists and has a valid entry for the current login, then the connect function can be called with any string as password, as it won't be used. It must be non empty though, as calling the connect function with an empty password would call the offline connection process otherwise.

Microsoft account

The easiest way to connect with a Microsoft account is to use an empty string as login in the connect function call. Botcraft will contact the microsoft authentication server, and display a link and a code in the console. You'll have to follow the instructions on this link in your browser to connect with the Microsoft account you want to use. Once done, botcraft will store the access token in the cache file for future use.

As the login is used as a key to identify the credentials, you can't use multiple accounts with this solution. In case you want to use multiple accounts, you need to use different logins for each one and set force_microsoft_account to true when calling the connect function. This way, each account will be identified in the cache file with the login you gave, allowing multiple accounts usage.

Clone this wiki locally