dommilosz / minecraft-auth

30 stars 3 forks source link

How to refresh Minecraft instance session after successfully authenticated (via Microsoft account)? #7

Closed fish90815 closed 2 years ago

fish90815 commented 2 years ago

Sorry it's may be a dumb question and a bit off-topic. I'm really new to this.

I'm trying to refresh my Minecraft session without the need to restart the game. I successfully get my new auth account information but the already "Invalid session "Minecraft instance still tell me "invalid session" after refreshing.

To be clear, the authentication flows are done and everything about this package works fine. Where does Minecraft instance check player's session? Do I still need to modify some files or runtime variables using the data which I get from this package? I think I really miss something in the last step. Need some advice. Thanks!!

dommilosz commented 2 years ago

Minecraft authenticates session when launching. After that if you join premium server and the session is invalid you get Invalid session. What is happening is probably you invalidate your old session token which Minecraft is still using when refreshing. You should tell Minecraft about the new token. If you are writing forge mod there is some function for this. Also you can checkout how it's made in my ReAuth fork. Feel free to ask more questions!

fish90815 commented 2 years ago

@dommilosz Thanks for the reply!^^

You should tell Minecraft about the new token.

is where I stuck. Quite frustrating because I feel like I'm almost done😂 I'm writing some JS scripts and trying to merge into Fabric Mods. I'll go check out your work.😊

dommilosz commented 2 years ago

Here is file from original ReAuth for fabric 1.16 that handles the authentication https://github.com/TechnicianLP/ReAuth/blob/1.16-Fabric/src/main/java/technicianlp/reauth/AuthHelper.java. It uses mixin to set the session. The mixin is in mixin folder

fish90815 commented 2 years ago

yeah That's probably what I'm looking for. Thanks for the advice and examples!! I'll close this issue.