feat: Multi-account support and auth exit fix#4
Merged
shahariaazam merged 2 commits intomainfrom Nov 6, 2025
Merged
Conversation
**Multi-Account Support:** - Store multiple Google accounts with email identification - Set default account with 'gscli auth set-default <email>' - Add --account flag to all commands (gmail, drive, calendar) - New commands: auth list, auth set-default, auth remove - Credentials stored per account in ~/.config/gscli/accounts.json **Auth Exit Fix:** - Clear timeout before closing server - Use server.close callback to ensure proper shutdown - Command now exits immediately after authentication **Account Management Commands:** - gscli auth list - Show all authenticated accounts - gscli auth set-default <email> - Set default account - gscli auth remove <email> - Remove specific account - gscli auth logout - Remove all accounts **Usage:** - gscli gmail list --account user@example.com - gscli drive list --account work@company.com - gscli calendar list (uses default account) **Storage:** - All accounts in: ~/.config/gscli/accounts.json - Automatic user email detection via Google OAuth2 API - Client credentials saved per account
- Add userinfo.email scope to fetch user email during auth - Improve getUserEmail error messages with detailed API responses - Better error handling in accounts.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements multi-account support allowing users to authenticate and manage multiple Google accounts, plus fixes the auth login hanging issue.
Issues Fixed
✅ Auth login no longer hangs - Command exits immediately after successful authentication
✅ Multi-account support - Manage multiple Google accounts seamlessly
New Features
Multi-Account Management
--accountflagNew Commands
gscli auth list- List all authenticated accountsgscli auth set-default <email>- Set default accountgscli auth remove <email>- Remove specific accountGlobal --account Flag
All commands now support
--account <email>option:gscli gmail list --account work@company.comgscli drive list --account personal@gmail.comgscli calendar list --account other@example.comUsage Examples
Technical Changes
Authentication Flow Fix
server.close(callback)for proper shutdownMulti-Account System
accounts.tsmodule for account management~/.config/gscli/accounts.jsonuserinfo.emailscope to fetch user emailAccount Storage
{ "default_account": "user@gmail.com", "accounts": { "user@gmail.com": { "email": "user@gmail.com", "client_id": "...", "client_secret": "...", "access_token": "...", "refresh_token": "...", "scope": "...", "token_type": "Bearer", "expiry_date": 123456789 } } }Updated All Commands
All support
--account <email>flagTesting
Breaking Changes
None - fully backward compatible