gws Account Switch
Use this alongside gws-shared, gws-gmail, gws-drive, and gws-calendar-safe when the user cares about which account gws should target.
Aliases
work->sourya4@trymyzone.compersonal->sourya4@gmail.comcolumbia-> authenticated mailboxsk5057@columbia.edu; normal outbound From identitysourya.kakarla@columbia.edu
Workflow
- Confirm which alias the user wants if it is not already clear.
- Check whether
~/.config/gws/accounts/<alias>.jsonexists. - If the alias file is missing, tell the user the account must be initialized first:
gws auth login --scopes https://www.googleapis.com/auth/drive.readonly,https://www.googleapis.com/auth/gmail.readonly,https://www.googleapis.com/auth/gmail.composegws-save-account <alias>
- For commands against a specific mailbox, use:
gws-account <alias> gmail +triagegws-account <alias> gmail +read --id <message-id>gws-gmail-draft <alias> --to <address> --subject <subject> --body-file <path>gws-account <alias> drive files list --params '{"pageSize": 5, "q": "trashed=false"}' --format jsongws-calendar-safe calendars --account <alias>for Calendar inventorygws-calendar-safe auth-plan --account <alias>before Calendar reauthorizationgws-account <alias> <service> <resource> ...for raw commands
Notes
gws-accountworks by settingGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILEto the alias file before executinggws.- Named alias state uses a private file-backed token cache by default so non-interactive Mac SSH sessions do not depend on GUI keychain access. Set
GWS_ACCOUNT_KEYRING_BACKEND=keyringonly when an interactive keychain is available. gws-save-accountexports the currently active decrypted credentials into~/.config/gws/accounts/<alias>.json.- On this machine, the saved aliases are expected to carry both Gmail read and Drive read scopes.
- Draft-enabled aliases additionally need
gmail.compose; this scope also technically permits sending. - After the alias exists, Calendar-enabled aliases use exactly
calendar.eventspluscalendar.calendarlist.readonly; preserve all existing non-Calendar scopes throughgws-calendar-safe auth-plan. - Calendar writes must use
gws-calendar-safe, never a rawgws calendarmutation. - The
columbiacredential still targets thesk5057@columbia.edumailbox, while new drafts should normally use its accepted default send-as addresssourya.kakarla@columbia.eduin the From header. - Prefer read-only Gmail and Drive flows unless the user explicitly asks to create a Gmail draft or perform another mutation.
- A vague request to “draft an email” means local text only. Gmail creation requires explicit Gmail-draft intent.
- Sending remains separate and always requires explicit confirmation.
- Never expose raw credential contents in chat or logs.