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

MLS v2 #143

Closed
wants to merge 9 commits into from
Closed

MLS v2 #143

wants to merge 9 commits into from

Conversation

drdeee
Copy link

@drdeee drdeee commented Jan 31, 2021

This is an improved version of #135 , since the repo of #135 was accidentally deleted. Also, in this pull request I improved the error handling when logging in with Microsoft, now it doesn't always come only "Report Plz!".Also various styles (frame size, background, ...) of the login button I have adjusted, although you could still improve things there (I can not CSS) and the link to the Minecraft store.
I hope that helps something,
DrDeee

@norhu1130 norhu1130 mentioned this pull request Jan 31, 2021
Closed
@coeragames
Copy link

Perfect

@drdeee
Copy link
Author

drdeee commented Feb 1, 2021

Here are all the error messages again, please adjust them again (or say me, what I should change) if they are not quite correct, my English is not the best (DeepL helped me 😄).

Error Message
Unspecific error An error occurred while logging in with Microsoft! For more detailed information please check the log. You can open it with CTRL + SHIFT + I.
User has not given the Microsoft Oauth app the permissions it needs. To use the NexusLauncher, you must agree to the required permissions! Otherwise you can't use this launcher with Microsoft accounts. Despite agreeing to the permissions you don't give us the possibility to do anything with your account, because all data will always be sent back to you (the launcher) IMMEDIATELY and WITHOUT WAY.
User does not own Minecraft You didn't buy Minecraft! Please use another Microsoft account or buy Minecraft.
Microsoft account is not linked to an Xbox account. Your Microsoft account is not connected to an Xbox account. Please create one.
User is not of age and Microsoft account is not associated with any family. Since you are not yet 18 years old, an adult must add you to a family in order for you to use NexusLauncher!

@dscalzi dscalzi self-requested a review February 1, 2021 23:13
@Freshmilkymilk
Copy link

Freshmilkymilk commented Feb 2, 2021

What I did to get this PR working:

  1. Merge this into the master branch (of course).
  2. Changed name of launcher in 81 of app/assets/js/microsoft.js and 324 of app/assets/js/scripts/login.js to match my launcher name.
  3. Build the distribution npm run dist
  4. Run the launcher and try to open the Microsoft login page. You will get an error message saying you need to register the application. Open this link, it will take you to https://portal.azure.com.
  5. Set the name to your launcher name. Set support account types to 'Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)'. Leave Redirect URI blank.
  1. Go to the Overview section and go the the Redirect URIs link in the same area with all the ID keys.
  2. Add a platform and choose Mobile and desktop applications then choose https://login.microsoftonline.com/common/oauth2/nativeclient as the URI
  1. Go to the Overview section to get the Application (client) ID.
  2. Use that API key in 5 of app/assets/js/microsoft.js (replace 'client id here') and 12 of index.js (replace 'client id here')
  3. Rebuild the launcher and see if you get any errors.
  4. Profit!

@coeragames
Copy link

coeragames commented Feb 2, 2021

What I did to get this PR working:

  1. Merge this into the master branch (of course).
  2. Changed name of launcher in 81 of app/assets/js/microsoft.js and 324 of app/assets/js/scripts/login.js to match my launcher name.
  3. Build the distribution npm run dist
  4. Run the launcher and try to open the Microsoft login page. You will get an error message saying you need to register the application. Open this link, it will take you to https://portal.azure.com.
  5. Set the name to your launcher name. Set support account types to 'Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)'. Leave Redirect URI blank.
  1. Go to the Overview section and go the the Redirect URIs link in the same area with all the ID keys.
  2. Add a platform and choose Mobile and desktop applications then choose https://login.microsoftonline.com/common/oauth2/nativeclient as the URI
  1. Go to the Overview section to get the Application (client) ID.
  2. Use that API key in 5 of app/assets/js/microsoft.js (replace 'client id here') and 12 of index.js (replace 'client id here')
  3. Rebuild the launcher and see if you get any errors.
  4. Profit!

Yes !
I think it would be a good idea to merge that, because it’s working, and without any server.

I have forgottent the second step 🤦

@GeekCornerGH
Copy link
Contributor

We need some other improvements, like logout, switch account or close msl Window

@coeragames
Copy link

We need some other improvements, like logout, switch account or close msl Window

Yes. It will be a good think to improve the ML support. I think someone will try to improve the code
But the essential is that it’s working, people with Minecraft on their Microsoft account can now use the launcher

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

What I did to get this PR working:

  1. Merge this into the master branch (of course).
  2. Changed name of launcher in 81 of app/assets/js/microsoft.js and 324 of app/assets/js/scripts/login.js to match my launcher name.
  3. Build the distribution npm run dist
  4. Run the launcher and try to open the Microsoft login page. You will get an error message saying you need to register the application. Open this link, it will take you to https://portal.azure.com.
  5. Set the name to your launcher name. Set support account types to 'Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)'. Leave Redirect URI blank.
  1. Go to the Overview section and go the the Redirect URIs link in the same area with all the ID keys.
  2. Add a platform and choose Mobile and desktop applications then choose https://login.microsoftonline.com/common/oauth2/nativeclient as the URI
  1. Go to the Overview section to get the Application (client) ID.
  2. Use that API key in 5 of app/assets/js/microsoft.js (replace 'client id here') and 12 of index.js (replace 'client id here')
  3. Rebuild the launcher and see if you get any errors.
  4. Profit!
  1. is fixed.

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

We need some other improvements, like logout, switch account or close msl Window

Microsoft oauth does not support logout if I am not mistaken. => my mistake, I will add this as soon as possible.

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

We need some other improvements, like logout, switch account or close msl Window

You can now close the login window, but unfortunately you can only use the default frame, because the oauth flow does not work in an iframe.

@dscalzi
Copy link
Owner

dscalzi commented Feb 2, 2021

Can you provide a link to the documentation used to set this up

@GeekCornerGH
Copy link
Contributor

GeekCornerGH commented Feb 2, 2021

We need some other improvements, like logout, switch account or close msl Window

You can now close the login window, but unfortunately you can only use the default frame, because the oauth flow does not work in an iframe.

Just, can you add an overlay on main window with a text saying "Waiting on Microsoft"? Like in Steam (when using PayPal)

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

Can you provide a link to the documentation used to set this up

https://wiki.vg/
Or did you mean the oauth app?

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

We need some other improvements, like logout, switch account or close msl Window

You can now close the login window, but unfortunately you can only use the default frame, because the oauth flow does not work in an iframe.

Just, can you add an overlay on main window with a text saying "Waiting on Microsoft"? Like in Steam (when using PayPal)

I'll take a look.

@dscalzi
Copy link
Owner

dscalzi commented Feb 2, 2021

steps noted here https://wiki.vg/Microsoft_Authentication_Scheme are missing and urls are different

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

The version of wiki.vg is basically the same, but the oauth/nativeclient endpoint from Microsoft allows login without a server. I also found this only through @norhu1130 in #135

@coeragames
Copy link

Perfect !
Now the window can close. I will try to change the text Login with Microsoft by a clean microsoft logo.
We just need to add logout (and multiple accounts support (i don’t think it is supported)).

@drdeee Thanks for contributing, it helps us a lot, MLS.

@GeekCornerGH
Copy link
Contributor

Perfect !
Now the window can close. I will try to change the text Login with Microsoft by a clean microsoft logo.
We just need to add logout (and multiple accounts support (i don’t think it is supported)).

@drdeee Thanks for contributing, it helps us a lot, MLS.

Its supported, official Launcher is the proof

@coeragames
Copy link

Perfect !
Now the window can close. I will try to change the text Login with Microsoft by a clean microsoft logo.
We just need to add logout (and multiple accounts support (i don’t think it is supported)).
@drdeee Thanks for contributing, it helps us a lot, MLS.

Its supported, official Launcher is the proof

Oh. But I didn’t knew that multiple Microsoft accounts support was supported.

@dscalzi
Copy link
Owner

dscalzi commented Feb 2, 2021

The version of wiki.vg is basically the same, but the oauth/nativeclient endpoint from Microsoft allows login without a server. I also found this only through @norhu1130 in #135

going to need more information on this if possible

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

@dscalzi, unfortunately, I couldn't find any direct documentation, so I've gathered everything I know here:
There are five different types of redirect URIs for Microsoft Oauth apps. One of them is "Mobile and Desktop Applications". With this one you don't need an app secret to log in with it, normally you can request the access token from microsoft only with authorization code and the corresponding app secret (= oauth 😄), but with this one, you don't need the app secret, so we can use this type for the launcher.

@drdeee
Copy link
Author

drdeee commented Feb 2, 2021

Perfect !
Now the window can close. I will try to change the text Login with Microsoft by a clean microsoft logo.
We just need to add logout (and multiple accounts support (i don’t think it is supported)).

@drdeee Thanks for contributing, it helps us a lot, MLS.

Multiple Account Support should bei easy, I will do that tomorrow.

@norhu1130
Copy link

I'm surprised that it has improved so much!

@coeragames
Copy link

coeragames commented Feb 3, 2021

Perfect !
Now the window can close. I will try to change the text Login with Microsoft by a clean microsoft logo.
We just need to add logout (and multiple accounts support (i don’t think it is supported)).
@drdeee Thanks for contributing, it helps us a lot, MLS.

Multiple Account Support should bei easy, I will do that tomorrow.

Oh. Perfect !
Hope we will quickly have a version with logout and multiple accounts support

@norhu1130 Yes xD

@drdeee
Copy link
Author

drdeee commented Feb 5, 2021

Commit 68879fa should work, but it has not been tested yet (I don't have a Microsoft account).

@coeragames
Copy link

Commit 68879fa should work, but it has not been tested yet (I don't have a Microsoft account).

Percect !
Is logout working ?

@drdeee
Copy link
Author

drdeee commented Feb 5, 2021

Commit 68879fa should work, but it has not been tested yet (I don't have a Microsoft account).

Percect !
Is logout working ?

I'am not shure, ist should, but I can't test it and there are no good docs.

@ReyADayer ReyADayer mentioned this pull request Feb 6, 2021
@TheFlash787
Copy link

This is definitely great progress so far. Once we can test that adding/removing accounts from the launcher works great, we need to look into developing the feature that can allow us to log out of Microsoft's account from the oauth window. Currently once you've logged into your Microsoft account in your browser, there's no way to switch Microsoft accounts. Adding a 'new account' just brings up the same window to allow the permissions without letting you change MS account. Something to do with cookies maybe?

@drdeee
Copy link
Author

drdeee commented Feb 8, 2021

Only change consent in the url. I will do that.

@chuhyeonjin
Copy link

The version of wiki.vg is basically the same, but the oauth/nativeclient endpoint from Microsoft allows login without a server. I also found this only through @norhu1130 in #135

going to need more information on this if possible

image

https://docs.microsoft.com/en-us/advertising/guides/authentication-oauth-live-connect?view=bingads-13

@sayersauce
Copy link

Firstly, many thanks for this pr. I am having some issues with Microsoft Authentication for multiple users. Sometimes it works great, other times it fails. When it fails, this is the error Cannot read property 'access_token' of undefined, which I am assuming corresponds to lines 205-207 in authmanager.js:
const accessToken = await Microsoft.getAccessToken(authCode)
ConfigManager.setMicrosoftAuth(accessToken)
const MCAccessToken = await Microsoft.authMinecraft(accessToken.access_token)
Which would then lead back to a problem when executing Microsoft.getAccessToken(). The issue only appears to occur for some users, and only at some times. Could this be a problem with limitations of azure such as the limit of authorizations you are allowed? Does anyone have any ideas?

@coeragames
Copy link

coeragames commented Feb 28, 2021

Firstly, many thanks for this pr. I am having some issues with Microsoft Authentication for multiple users. Sometimes it works great, other times it fails. When it fails, this is the error Cannot read property 'access_token' of undefined, which I am assuming corresponds to lines 205-207 in authmanager.js:
const accessToken = await Microsoft.getAccessToken(authCode)
ConfigManager.setMicrosoftAuth(accessToken)
const MCAccessToken = await Microsoft.authMinecraft(accessToken.access_token)
Which would then lead back to a problem when executing Microsoft.getAccessToken(). The issue only appears to occur for some users, and only at some times. Could this be a problem with limitations of azure such as the limit of authorizations you are allowed? Does anyone have any ideas?

Me too, I have this error. I think it will be a good idea to fix it.

Also, I think we should close the Waiting for Microsoft widget when we close the login page

@drori200
Copy link

drori200 commented Mar 8, 2021

I have gotten a new minecraft account meaning it uses the microsoft login system. If you need me to test HMU in DMs or the Aventium Softworks server, drori#4435

@binrate
Copy link

binrate commented Mar 9, 2021

TO-DO: Replace the outdated "request" library by node-fetch or axios. I should be able to do that by tomorrow.

@GeekCornerGH
Copy link
Contributor

TO-DO: Replace the outdated "request" library by node-fetch or axios. I should be able to do that by tomorrow.

node-fetch > all

@dscalzi
Copy link
Owner

dscalzi commented Mar 12, 2021

got is better

@coeragames
Copy link

got is better

Got it better, but there is still bugs.
Some of the players that use my launcher with Microsoft Accounts cannot login due to "Cannot read acess_token of undefined"
I don't know if its comming from the launcher code, or from Microsoft.
I hope we will be able to patch this bug quickly: its the only annoying one.

PS: most of the launchers are experiencing trouble with Microsoft Login

@binrate
Copy link

binrate commented Jun 2, 2021

got is better

Got it better, but there is still bugs.
Some of the players that use my launcher with Microsoft Accounts cannot login due to "Cannot read acess_token of undefined"
I don't know if its comming from the launcher code, or from Microsoft.
I hope we will be able to patch this bug quickly: its the only annoying one.

PS: most of the launchers are experiencing trouble with Microsoft Login

I’m having 0 issues on my custom launcher. I’m using node fetch and axios without oauth/nativeclient. Can share my code if needed. Good luck fellow coders 😌

@coeragames
Copy link

got is better

Got it better, but there is still bugs.
Some of the players that use my launcher with Microsoft Accounts cannot login due to "Cannot read acess_token of undefined"
I don't know if its comming from the launcher code, or from Microsoft.
I hope we will be able to patch this bug quickly: its the only annoying one.
PS: most of the launchers are experiencing trouble with Microsoft Login

I’m having 0 issues on my custom launcher. I’m using node fetch and axios without oauth/nativeclient. Can share my code if needed. Good luck fellow coders 😌

I would love to.
I've sent you a message on Discord :)

@dscalzi
Copy link
Owner

dscalzi commented Jun 7, 2021

Since I keep getting quoted I'll clarify:

  1. Axios had 0 maintainers at one point. I'm not comfortable using a library that is not being maintained. Unmaintained libraries are typically deprecated and then you have to rewrite everything (which is something that must happen already because we're currently using request). It seems like they have someone merging PRs now, but doesnt really matter given that there is a better alternative.
  2. Got is maintained, and has been maintained. See feature comparison https://github.com/sindresorhus/got#comparison

@dscalzi
Copy link
Owner

dscalzi commented Jul 19, 2021

@drdeee please rebase this PR. It's clear that I wont be able to work on/complete my own implementation for this. I'll review it and if it's good enough it will go into master.

@Richienb Richienb mentioned this pull request Aug 22, 2021
@EarthKingdoms
Copy link

Hello,
When I create my Register App, I do everything as explained in a message above but when I try to connect, it gives me an infinite load, can someone help me?
Thank you

@alduish alduish mentioned this pull request Feb 6, 2022
@dscalzi
Copy link
Owner

dscalzi commented Feb 9, 2022

Thanks everyone, official support will be coming through this PR #216

Relevant links:

@dscalzi dscalzi closed this Feb 9, 2022
@dscalzi dscalzi mentioned this pull request Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.