Voxelum / minecraft-launcher-core-node

Provide packages to install Minecraft, launch Minecraft and more to build launcher with NodeJs/Electron!
https://docs.xmcl.app/en/core/
MIT License
174 stars 25 forks source link

Microsoft Login support? #232

Closed JoLoZ closed 1 year ago

JoLoZ commented 2 years ago

I might just be blind, but is there any way to log users in using the new Microsoft login system? I didn't find anything in the docs about it.

bluefoxy009 commented 2 years ago

You'll have to implement it yourself, I recommend reading https://wiki.vg/Microsoft_Authentication_Scheme

ci010 commented 2 years ago

Great question. I'm really wondering should I put anything to this repo about the Microsoft login, as the ideal process required developer to have an individual azure application.

I can describe the general process here, and you can see the overall implementation here

First you need to register an azure app:

  1. Go azure portal, register an azure account and go "Active Directory"
  2. Find App registrations on side bar
  3. Register an app there, and get the application (client) ID

Then you need to implement oauth in your launcher. I suggest you to use @azure/msal-node.

  1. Acquire Microsoft token (see here)
    • This is done by the public oauth client. (See the public client described in @azure/msal-node)
    • This requires your launcher open browser to login Microsoft, and callback to launcher
    • In my implementation, it calls back to my website, and my website calls back to my launcher via custom protocol xmcl:// (register by electron)
  2. Acquire Xbox token (see here)
    • This is also oauth like process... but it's auth to Xbox service... See the wiki.vg or my implementation...
  3. Login Minecraft with Xbox token you just get (see here)
    • You will get our access token here... finally...
      1. Check game ownership and user game profile.
    • You can find source code in the rest of the method

As you see, the process is complex and I'm not sure if this is a general way to implement this.

Should I integrate this into the library?

Pixelwarp commented 2 years ago

@ci010 yes

olliedean commented 2 years ago

Could use this library for context: dommilosz/minecraft-auth

ci010 commented 1 year ago

@olliedean @Pixelwarp see user module new instruction. It grabs part of the MS authentication.