Skip to content

Add browser based login#75

Merged
bitsnaps merged 2 commits intoHeyPuter:masterfrom
reynaldichernando:browser-login
Feb 4, 2026
Merged

Add browser based login#75
bitsnaps merged 2 commits intoHeyPuter:masterfrom
reynaldichernando:browser-login

Conversation

@reynaldichernando
Copy link
Contributor

  • puter.js recently added a getAuthToken function which is meant to be used by nodejs cli apps
  • this will open up a browser and show a login window
  • it means we don't have to manually do fetch to the login endpoint

@reynaldichernando
Copy link
Contributor Author

hi @bitsnaps , when you get the chance, could you help test and review this? thank you!

@bitsnaps
Copy link
Collaborator

bitsnaps commented Feb 3, 2026

Thanks @reynaldichernando ! While this may reduce the friction of maintaining multiple auth related code, this could limit some use cases in some conditions: automated env (CI/CD), terminal-only access, even termux from mobile... my best bet is give the user choice (e.g. Login via browser or via Credentials)

@reynaldichernando
Copy link
Contributor Author

hi @bitsnaps , thanks for the feedback, you are right about the concerns above

i think what i can do to cater the above is, to first try the getAuthToken if it throws error due to not being able to open browser, it will fallback to the old method of username and password

as for automated env, i think with the direction puter is going is using an authToken rather than username + password for automated systems, so i won't handle this in the current PR

@reynaldichernando
Copy link
Contributor Author

actually after testing the getAuthToken it doesn't throw error or signal anything when it fails to open a browser (i tested)
the second best idea i have is to have some sort of flag for puter login which might be the elegant approach
puter login --with-credentials or something like that, reference
https://cli.github.com/manual/gh_auth_login

@reynaldichernando
Copy link
Contributor Author

updates:

  • re added username and password login via --with-credentials argument
  • we can also explicitly specify web/browser based via --web
    • btw we can extend this down the line with something like --with-token for automated systems
  • moved the host prompt to just using argument in --host <host>
  • fix the --save implementation, previously it wasn't working
  • also adjust the web based login so it doesn't have to prompt the username, since it can be derived after getting the token

kindly help to review @bitsnaps 🙏

i did test them and all of it works, except for 2FA because none of my account is 2FA enabled, plus i'm having some sort of issue in prod trying to enable it
HeyPuter/puter#2412

@bitsnaps bitsnaps merged commit 3c7f6b4 into HeyPuter:master Feb 4, 2026
3 checks passed
@bitsnaps
Copy link
Collaborator

bitsnaps commented Feb 4, 2026

LGTM, I thought of the same thing except of --with-credentials (would be --no-browser like more explicit, borrowed from Jupyter) but that's fine. Thanks so much @reynaldichernando.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants