Jump to content

Recommended Posts

Posted

I was trying to log into Minecraft inside of Eclipse so could try some mods out on servers. 
I’ve tried adding

—username username

And —password password

into the program arguments but in the console it shows that the argument password is being ignored and I’m not logged in.

Does anyone know any other way to log into my Minecraft Account inside of Eclipse?

  • Like 1
Posted (edited)

this is no longer possible with a Mojang Account,
irrc you need to use the access token form the Launcher

also why do you want to login in dev environment?
there is no reason to be logged in

Edited by Luis_ST
  • Like 1
  • 4 weeks later...
Posted
On 3/5/2022 at 8:28 AM, Luis_ST said:

this is no longer possible with a Mojang Account,
irrc you need to use the access token form the Launcher

also why do you want to login in dev environment?
there is no reason to be logged in

This isn't true HOWEVER its super complicated to do and you have to change the command every time. 

Below is a code snippet from a custom minecraft launcher I'm working on so there may be some unnecessary steps focus mainly on the HTTP connections, request types, and request bodys/url endpoints. Forewarning this is incredibly complicated and i would advise against it. If you need to test your mod on a server just put it in offline mode.
 

Spoiler


public static void signUserIn() throws Exception {	
        String content;
        JSONObject playerJson = new JSONObject();
        if (AppUtils.accountsStatus == 1) {
            SignInFrame sif = new SignInFrame().showSignIn();
            while (sif.code == null) {
                Thread.sleep(1);
            }

            content = String.format(
                    "client_id=%s" +
                            "&code=%s" +
                            "&grant_type=authorization_code" +
                            "&redirect_uri=%s",
                    "[Redacted]", //You'll need to regester an app with Azure to get this code
                    sif.code,
                    "https://login.live.com/oauth20_desktop.srf"
            );
        } else {
            content = String.format(
                    "client_id=%s" +
                            "&refresh_token=%s" +
                            "&grant_type=refresh_token" +
                            "&redirect_uri=%s",
                    "[Redacted]",
                    AppUtils.accountsInfo.getJSONObject(AppUtils.activeAccount).getString("refresh_token"),
                    "https://login.live.com/oauth20_desktop.srf"
            );
        }

        CloseableHttpClient client = HttpClients.createDefault();

        HttpPost msaLogin = new HttpPost("https://login.live.com/oauth20_token.srf");
        msaLogin.setEntity(new StringEntity(content, ContentType.APPLICATION_FORM_URLENCODED));

        CloseableHttpResponse msaResponse = client.execute(msaLogin);
        JSONObject msaResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(msaResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        content = String.format(
                "{" +
                        "\"Properties\": {" +
                        "\"AuthMethod\": \"RPS\"," +
                        "\"SiteName\": \"user.auth.xboxlive.com\"," +
                        "\"RpsTicket\": \"d=%s\"" +
                        "}," +
                        "\"RelyingParty\": \"http://auth.xboxlive.com\"," +
                        "\"TokenType\": \"JWT\"" +
                        "}",
                msaResponseJSON.getString("access_token")
        );

        HttpPost xblLogin = new HttpPost("https://user.auth.xboxlive.com/user/authenticate");
        xblLogin.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
        xblLogin.setHeader(HttpHeaders.ACCEPT, "application/json");

        CloseableHttpResponse xblResponse = client.execute(xblLogin);
        JSONObject xblResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(xblResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        content = String.format(
                "{\n" +
                        "\"Properties\": {" +
                        "\"SandboxId\": \"RETAIL\"," +
                        "\"UserTokens\": [" +
                        "\"%s\"" +
                        "]" +
                        "}," +
                        "\"RelyingParty\": \"rp://api.minecraftservices.com/\"," +
                        "\"TokenType\": \"JWT\"" +
                        "}",
                xblResponseJSON.getString("Token")
        );

        HttpPost xstsPost = new HttpPost("https://xsts.auth.xboxlive.com/xsts/authorize");
        xstsPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
        xstsPost.setHeader(new BasicHeader(HttpHeaders.ACCEPT, "application/json"));

        CloseableHttpResponse xstsResponse = client.execute(xstsPost);
        JSONObject xstsResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(xstsResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        content = String.format(
                "{" +
                        "\"identityToken\" : \"XBL3.0 x=%s;%s\"," +
                        "\"ensureLegacyEnabled\" : true" +
                        "}",
                xstsResponseJSON.getJSONObject("DisplayClaims").getJSONArray("xui").getJSONObject(0).getString("uhs"),
                xstsResponseJSON.getString("Token")
        );

        HttpPost mctPost = new HttpPost("https://api.minecraftservices.com/authentication/login_with_xbox");
        mctPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));

        CloseableHttpResponse mctResponse = client.execute(mctPost);
        JSONObject mctResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(mctResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        HttpGet mcGet = new HttpGet("https://api.minecraftservices.com/minecraft/profile");
        mcGet.setHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, String.format(
                "Bearer %s",
                mctResponseJSON.getString("access_token")
        )));
        CloseableHttpResponse mcResponse = client.execute(mcGet);
        JSONObject mcResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(mcResponse.getEntity().getContent())).lines().collect(Collectors.joining()));
        System.out.println(mcResponseJSON.toString());

        JSONObject playerInfo = new JSONObject();
        playerInfo.put("refresh_token", msaResponseJSON.getString("refresh_token"));
        playerInfo.put("ms_id", mctResponseJSON.getString("username"));
        for (Object sk : mcResponseJSON.getJSONArray("skins")) {
            JSONObject skj = ((JSONObject) sk);
            if (skj.getString("state").equalsIgnoreCase("active")) {
                playerInfo.put("skin_url", skj.getString("url"));
                break;
            }
        }
        playerInfo.put("user_name", mcResponseJSON.getString("name"));
        AppUtils.accountsInfo.put(mcResponseJSON.getString("id"), playerInfo);
        AppUtils.accountsInfo.put("active_account", mcResponseJSON.getString("id"));
        AppUtils.activeAccount = mcResponseJSON.getString("id");
        AppUtils.accountsStatus = 0;
        AppUtils.updateSkinImage();
    }

    public static void signSecondaryUserIn() throws Exception {
        String content;
        JSONObject playerJson = new JSONObject();
        SignInFrame sif = new SignInFrame().showSignIn();
        while (sif.code == null) {
            Thread.sleep(1);
        }

        content = String.format(
                "client_id=%s" +
                        "&code=%s" +
                        "&grant_type=authorization_code" +
                        "&redirect_uri=%s",
                "60ea6a7c-d173-43bd-97af-8b8ea1108a31",
                sif.code,
                "https://login.live.com/oauth20_desktop.srf"
        );

        CloseableHttpClient client = HttpClients.createDefault();

        HttpPost msaLogin = new HttpPost("https://login.live.com/oauth20_token.srf");
        msaLogin.setEntity(new StringEntity(content, ContentType.APPLICATION_FORM_URLENCODED));

        CloseableHttpResponse msaResponse = client.execute(msaLogin);
        JSONObject msaResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(msaResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        content = String.format(
                "{" +
                        "\"Properties\": {" +
                        "\"AuthMethod\": \"RPS\"," +
                        "\"SiteName\": \"user.auth.xboxlive.com\"," +
                        "\"RpsTicket\": \"d=%s\"" +
                        "}," +
                        "\"RelyingParty\": \"http://auth.xboxlive.com\"," +
                        "\"TokenType\": \"JWT\"" +
                        "}",
                msaResponseJSON.getString("access_token")
        );

        HttpPost xblLogin = new HttpPost("https://user.auth.xboxlive.com/user/authenticate");
        xblLogin.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
        xblLogin.setHeader(HttpHeaders.ACCEPT, "application/json");

        CloseableHttpResponse xblResponse = client.execute(xblLogin);
        JSONObject xblResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(xblResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        content = String.format(
                "{\n" +
                        "\"Properties\": {" +
                        "\"SandboxId\": \"RETAIL\"," +
                        "\"UserTokens\": [" +
                        "\"%s\"" +
                        "]" +
                        "}," +
                        "\"RelyingParty\": \"rp://api.minecraftservices.com/\"," +
                        "\"TokenType\": \"JWT\"" +
                        "}",
                xblResponseJSON.getString("Token")
        );

        HttpPost xstsPost = new HttpPost("https://xsts.auth.xboxlive.com/xsts/authorize");
        xstsPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));
        xstsPost.setHeader(new BasicHeader(HttpHeaders.ACCEPT, "application/json"));

        CloseableHttpResponse xstsResponse = client.execute(xstsPost);
        JSONObject xstsResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(xstsResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        content = String.format(
                "{" +
                        "\"identityToken\" : \"XBL3.0 x=%s;%s\"," +
                        "\"ensureLegacyEnabled\" : true" +
                        "}",
                xstsResponseJSON.getJSONObject("DisplayClaims").getJSONArray("xui").getJSONObject(0).getString("uhs"),
                xstsResponseJSON.getString("Token")
        );

        HttpPost mctPost = new HttpPost("https://api.minecraftservices.com/authentication/login_with_xbox");
        mctPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON));

        CloseableHttpResponse mctResponse = client.execute(mctPost);
        JSONObject mctResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(mctResponse.getEntity().getContent())).lines().collect(Collectors.joining()));

        HttpGet mcGet = new HttpGet("https://api.minecraftservices.com/minecraft/profile");
        mcGet.setHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, String.format(
                "Bearer %s",
                mctResponseJSON.getString("access_token")
        )));
        CloseableHttpResponse mcResponse = client.execute(mcGet);
        JSONObject mcResponseJSON = new JSONObject(new BufferedReader(new InputStreamReader(mcResponse.getEntity().getContent())).lines().collect(Collectors.joining()));
        System.out.println(mcResponseJSON.toString());

        JSONObject playerInfo = new JSONObject();
        playerInfo.put("refresh_token", msaResponseJSON.getString("refresh_token"));
        playerInfo.put("ms_id", mctResponseJSON.getString("username"));
        for (Object sk : mcResponseJSON.getJSONArray("skins")) {
            JSONObject skj = ((JSONObject) sk);
            if (skj.getString("state").equalsIgnoreCase("active")) {
                playerInfo.put("skin_url", skj.getString("url"));
                break;
            }
        }
        playerInfo.put("user_name", mcResponseJSON.getString("name"));
        AppUtils.accountsInfo.put(mcResponseJSON.getString("id"), playerInfo);
        AppUtils.accountsInfo.put("active_account", mcResponseJSON.getString("id"));
        AppUtils.activeAccount = mcResponseJSON.getString("id");
        AppUtils.accountsStatus = 0;
        AppUtils.updateSkinImage();

Sif is a JavaFX panel with Microsoft website embedded into it:

public class SignInFrame extends JFrame {

    WebEngine we;
    public String code;
    WebView wv;

    public SignInFrame showSignIn() throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        this.setSize(450, 500);
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.setTitle("Sign in to minecraft");
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                super.windowClosing(e);

                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException classNotFoundException) {
                    classNotFoundException.printStackTrace();
                }
                JOptionPane.showMessageDialog(new JFrame(), "You must sign in to continue", "Sign In", JOptionPane.WARNING_MESSAGE);

            }
        });


        String redirectUrl = URLEncoder.encode("https://login.live.com/oauth20_desktop.srf", StandardCharsets.UTF_8);
        URL url = new URL("https://login.live.com/oauth20_authorize.srf?client_id=[Redacted]&response_type=code&redirect_uri=" + redirectUrl + "&scope=XboxLive.signin%20offline_access");

        JFXPanel jfxPanel = new JFXPanel();
        this.add(jfxPanel);
        Platform.runLater(() -> {
            Platform.setImplicitExit(true);
            wv = new WebView();
            we = wv.getEngine();
            we.setJavaScriptEnabled(true);
            Scene sc = new Scene(wv);
            jfxPanel.setScene(sc);
            we.load(url.toString());


            we.locationProperty().addListener((obs, oldLocation, newLocation)->{
                if (newLocation.contains("https://login.live.com/oauth20_desktop.srf")) {
                    code = newLocation.split("code=")[1].split("&")[0];
                    this.dispose();
                }
            });
        });

        return this;
    }
}

Learn more about API authentication here: https://mojang-api-docs.netlify.app/authentication/msa.html

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.