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

Add method to login with access token #235

Closed Pixelwarp closed 1 year ago

Pixelwarp commented 2 years ago

Basically could be this ` const { loginWithAccessToken } = require('@xmcl/user');

const user = loginWithAccessToken('access_token'); // returns null if access token is invalid

// User methods user.username; user.accessToken; `

ci010 commented 2 years ago

Can you describe it more? (I don't know how to get username or other from only accessToken). In old protocol, we can have refresh operation by input client & access token to get the selectedProfile.

Or, are you trying to resolve the Microsoft login issue (#232)?

Pixelwarp commented 2 years ago

@ci010 You could use https://api.minecraftservices.com/minecraft/profile, then add a header called "Authorization" with the value of "Bearer ACCESS_TOKEN" then it would return current skin and username and UUID, and etc

Pixelwarp commented 2 years ago

GET Request

ci010 commented 1 year ago

See new release version https://github.com/Voxelum/minecraft-launcher-core-node/blob/master/packages/user/mojang.ts#L243 should resolve this issue.