CmlLib / CmlLib.Core.Auth.Microsoft

Minecraft Login with Microsoft Xbox account
MIT License
22 stars 4 forks source link

Get XSTS not working when RelyingParty is http://xboxlive.com #9

Closed EvanEvan-17 closed 2 years ago

EvanEvan-17 commented 2 years ago

I use this library and I'm trying to also get user's Xbox Live Profile info for my needs, but when the RelyingParty is http://xboxlive.com it throws XboxAuthException (maybe) and the success XSTS token result is the exception message. Like what? It success but it throws exception and a success result is the message. Can you fix this?

AlphaBs commented 2 years ago

can you attach your code?

EvanEvan-17 commented 2 years ago

I'm customising LoginHandler and this is the LoginFromOAuth code:

public virtual async Task<SessionCacheData> LoginFromOAuth(MicrosoftOAuthResponse msToken)
        {
            var xsts = await GetXsts(msToken);

            var xstsXboxLive = await GetXsts(msToken, "http://xboxlive.com"); // I have added RelyingParty parameter and it throws exception when RelyingParty is http://xboxlive.com
            var mojangToken = await GetMojangXboxToken(xsts);
            var msession = await GetMSession(mojangToken, new MSession());
            var sessionCache = new SessionCacheData
            {
                MicrosoftOAuthToken = msToken,
                XstsToken = xsts,
                MojangXboxToken = mojangToken,
                GameSession = msession,
                LiveXstsToken = xstsXboxLive,
            };
            saveSessionCache(sessionCache);
            return sessionCache;
        }

In addition, I am using MsalClient from CmlLib.Core.Auth.Microsoft package.

EvanEvan-17 commented 2 years ago

Are there any fix?

AlphaBs commented 2 years ago

fixed. update package XboxAuthNet to 2.1.0

EvanEvan-17 commented 2 years ago

OK, it worked. Thank you very much! Before this fixed, I use the Minecraft Access Token to authenticate with my API then decode the token to get the XUID, and now I can DIRECTLY get the user's Xbox Live Profile. Awesome!