-
Notifications
You must be signed in to change notification settings - Fork 25
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
Supply MSA bearer token directly #108
base: master
Are you sure you want to change the base?
Conversation
Why not implement this with the existing cache system? Can you explain what the exact use case for this is? |
How would that look? Afaik there is no way to directly supply the minecraft token, which would make devops in envs that are not your local machine much easier, without touching the browser. (in comparison to creating a |
Can you explain the use case here? Where is the token being obtained and why does it need to be passed here? Why should we maintain this functionality? |
Use case: Deploying a mineflayer bot on headless servers. No need for opening the browser and one can be sure that the bot joins without any copying of .minecraft/npm_cache files. It just makes deployment a lot easier. How to obtain: Benefits:
Why to maintain: It's just a simple |
Anyways, I created this PR because I couldn't get the session and accessToken parameters of createBot to work, if you have any insight on that I would be very grateful |
I also just realized that the msa token goes invalid after a day or so, so this PR can be closed. I would still be very thankful for help with using the accessToken and session parameters |
I think you misunderstood how the authentication system here was designed. We have a caching system for the explicit purpose of not having to sign in multiple times. All the tokens are cached, refreshed and managed automatically by the library. Once you sign in manually with the code based authentication flow once there's no need to manually sign in again. Unless you spend months with an inactive session, the library can refresh any expired tokens on its own without needing user intervention. If you need to deploy remotely the mechanism is the same as local--best thing to do would be to sign in manually once and persist the cache so it doesn't have to be updated again. You can also add in the cached authentication tokens as part of your deployment but I don't advise that for security reasons. |
I now implemented Essential Mod's authentication flow to refresh tokens. (They handle token refreshing in a slightly different way) If I can make the PR any more maintainable or concise, please let me know |
This PR enables one to supply the MSA bearer token directly (which simplifies a lot for users who do not want to rely on the cache system)
PrismarineJS/node-minecraft-protocol#1323 enables easy access for bot: