Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticating with a Microsoft account #782

Closed
viktordanov opened this issue Dec 1, 2020 · 7 comments
Closed

Authenticating with a Microsoft account #782

viktordanov opened this issue Dec 1, 2020 · 7 comments

Comments

@viktordanov
Copy link

viktordanov commented Dec 1, 2020

Is your feature request related to a problem? Please describe.
Mojang are transitioning to Microsoft authentication and intend to completely switch over to it in the future. I haven't been able to figure out how to use my new Microsoft account with #createClient().

Describe the solution you'd like
It would be great for the package to treat Microsoft and Mojang accounts equal, i.e. supply an email and a password for the username and password ClientOptions

Describe alternatives you've considered
I've attempted to authenticate my Microsoft account with the access- and clientTokens I extracted from my .minecraft/launcher-accounts.json file but I'm not sure what username to supply. I've tried using my Microsoft email, my Minecraft username, and my Xbox username (seeing as this one is also saved in launcher-accounts.json I figured it was worth a shot) but none has worked.

@rom1504
Copy link
Member

rom1504 commented Dec 1, 2020 via email

@rom1504
Copy link
Member

rom1504 commented Dec 7, 2020

https://wiki.vg/Microsoft_Authentication_Scheme now we have some doc, implementation can start

@rom1504
Copy link
Member

rom1504 commented Dec 9, 2020

03:04
so i had been rev-engineering the MSA/minecraft login for the last few days. saw minidigger released it. however, i can confirm, you can use your own Azure Application instead of MCs
03:05
https://gist.github.com/rbrick/be8ed86864fc5d77aa6c979053cfc892#file-msa-go-L20 my test code is a bit of a mess, but works

@extremeheat
Copy link
Member

I don't think there's much else to reverse-engineer, it looks like standard Xbox auth the same way it's done on Bedrock. There's existing libraries as such that do this auth already, and a lot of complex docs from MS if anyone wants to read them.

You don't need to even auth like the launcher, there's other non-oauth ways to sign in, as is done in https://github.com/minecraft-linux/msa/blob/0dd792abe72ee0526533765a89017255bb394ad5/src/network/server_config.cpp

Oauth based, https://github.com/Sandertv/gophertunnel/tree/master/minecraft/auth

Since the MS auth step is independent of the Xbox auth step, you can use any auth method as long as you use the valid scope with xbox permissions, the ms auth token is all you need to talk to the Xbox API. This can be done entirely programmatically, but not in a stable/practical way as there's lots of different ways to auth to microsoft (2FA, phone/email code w/o 2FA, password-based) and alot of errors that can happen to make it a really fragile process. I tried to make it work based on existing stuff (see here) but got blocked for a bit, so I'd recommend using a non-personal account for testing.

Also tried out https://github.com/XboxReplay/xboxlive-auth - which seems up-to-date and I was able to get it working on a new testing ms account, although signins had to be approved seemingly randomly on the account page when I signed in. Though this may be because of a lot of authentication attempts, not sure.

For node projects, the easiest way could be could be to use official @azure/node-msal for ms auth (since this does change somewhat often) + xboxlive-auth or build on top of xboxlive-auth. Presumably we could add support for both browser-based and also a credential based system for people with accounts that have passwords enabled without 2FA.

@Karang
Copy link
Contributor

Karang commented Dec 10, 2020

I confirm that https://github.com/XboxReplay/xboxlive-auth is working, it can be tried with the code:

const XboxLiveAuth = require('@xboxreplay/xboxlive-auth')

const email = 'xxxxxx'
const password = 'xxxxxx'

XboxLiveAuth.authenticate(email, password, {XSTSRelyingParty: 'rp://api.minecraftservices.com/'})
    .then(console.info)
    .catch(console.error)

It needs a ms account with xbl enabled.

@kashalls
Copy link
Contributor

I confirm that https://github.com/XboxReplay/xboxlive-auth is working, it can be tried with the code:

const XboxLiveAuth = require('@xboxreplay/xboxlive-auth')

const email = 'xxxxxx'
const password = 'xxxxxx'

XboxLiveAuth.authenticate(email, password, {XSTSRelyingParty: 'rp://api.minecraftservices.com/'})
    .then(console.info)
    .catch(console.error)

It needs a ms account with xbl enabled.

If there is no XBOX Live Account associated with the Microsoft Account, you will recieve a 500 Status Code with a Generic INTERNAL_SERVER_ERROR reason.

XboxReplayError: Request failed with status code 401
    at Object.internal (/node_modules/@xboxreplay/errors/dist/index.js:33:77)
    at /node_modules/@xboxreplay/xboxlive-auth/dist/core/xboxlive/index.js:80:32
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  __XboxReplay__: true,
  details: { statusCode: 500, reason: 'INTERNAL_SERVER_ERROR' }
}

@rom1504
Copy link
Member

rom1504 commented Dec 13, 2020

now supported

@rom1504 rom1504 closed this as completed Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants