adepierre / Botcraft

Botcraft is a cross-platform C++ library to create bots that connect and interact with Minecraft servers with (optional) integrated OpenGL renderer
GNU General Public License v3.0
405 stars 43 forks source link

Improve caching of authorization tokens #60

Closed maxsupermanhd closed 2 years ago

maxsupermanhd commented 2 years ago

Fixes #59 (now there is username and uuid cached too) Fixes #58

adepierre commented 2 years ago

Could you clarify what this PR does for legacy Mojang accounts? From what I've rapidly checked, I don't think it improves caching for them. So #58 would still be an issue right?

maxsupermanhd commented 2 years ago

Could you clarify what this PR does for legacy Mojang accounts? From what I've rapidly checked, I don't think it improves caching for them. So #58 would still be an issue right?

It will cache token and expire date as well as profile information allowing reuse of it if it is not yet expired. Reacquires it if expired using cached microsoft token and refreshes microsoft token too. I did not touched legacy auth method (one with username and password) because I am lazy and they will be discontinued shortly anyways. Not that it is impossible, just by using update functions it can be cached too...

adepierre commented 2 years ago

I think it's important to keep both connection solutions with the same level of functionalities, at least as long as they are both supported by the game.

Especially since #58 as it means that not caching can cause failed login attempts.

maxsupermanhd commented 2 years ago

I think it's important to keep both connection solutions with the same level of functionalities, at least as long as they are both supported by the game.

Especially since #58 as it means that not caching can cause failed login attempts.

I don't know why you did not hit that issue, I think mojang services have less rate limiting. This affects getting minecraft token from microsoft, I don't know about and did not hit any rate limiting from mojang side so far so I added caching only for what I had issues with. I test everything on real servers in online mode and I can have maybe 50 logins per hour and it drives microsoft security nuts (not blaming microsoft on that one). Due to my lack of access ram I can not host a server on my pc with both java and botcraft clients running, not taking into account that I have atom editor and it eats around 400mb too (I already accepted that fact that I am coding without browser now anyways).

adepierre commented 2 years ago

All right so I think I'll try to add the caching for Mojang accounts to this PR before merging it so both connection methods are similar in term of functionalities.

maxsupermanhd commented 2 years ago

Please make it a different PR or push changes directly to master, this caching is required to use botcraft with Microsoft account, it has nothing to do with deprecated mojang authorization.

adepierre commented 2 years ago

All right I won't add it to this PR and do it somewhere else