Skip to content

Nikolai-Iakubovskii/gws-multi-profile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gws-multi-profile

Tiny wrappers for running the official gws with multiple isolated accounts on one machine.

Built by Nikolai Iakubovskii, indie developer behind MistyWay and AuroraMe. I made this because one gws login was never enough in real work.

gws is great, but by default it behaves like a single-user CLI. This repo adds one simple trick:

  • each profile gets its own config directory
  • each command runs with its own GOOGLE_WORKSPACE_CLI_CONFIG_DIR
  • you can stay logged into multiple Google accounts at the same time

No forks. No patched gws. No credential files in this repo.

What You Get

  • gws-profile.sh
    Run any gws command inside one named profile.

  • gws-login-all.sh
    Start multiple gws auth login flows in parallel.

Why This Is Useful

If you work across multiple Google accounts, you usually hit one of these problems:

  • logging into one account breaks another
  • you forget which token is active
  • Gmail / Drive / Sheets work is mixed across clients or projects

This wrapper fixes that by separating gws state per profile:

~/.config/gws-work
~/.config/gws-personal
~/.config/gws-client-a

Requirements

  • macOS or Linux shell environment
  • gws installed
  • bash or zsh

Install gws:

npm install -g @googleworkspace/cli

Quick Start

Clone the repo:

git clone https://github.com/Nikolai-Iakubovskii/gws-multi-profile.git
cd gws-multi-profile
chmod +x gws-profile.sh gws-login-all.sh

Log into two accounts:

./gws-login-all.sh work personal

Check status:

./gws-profile.sh work auth status
./gws-profile.sh personal auth status

Run different commands under different accounts:

./gws-profile.sh work gmail users messages list \
  --params '{"userId":"me","maxResults":5}' \
  --format json

./gws-profile.sh personal drive files list \
  --params '{"pageSize":10}' \
  --format json

How It Works

The whole idea is this:

GOOGLE_WORKSPACE_CLI_CONFIG_DIR=~/.config/gws-work gws ...
GOOGLE_WORKSPACE_CLI_CONFIG_DIR=~/.config/gws-personal gws ...

That is all.

The wrappers just make it repeatable and less annoying.

Scripts

gws-profile.sh

Usage:

./gws-profile.sh <profile> <gws args...>

Examples:

./gws-profile.sh work auth status
./gws-profile.sh client-a gmail users messages list --params '{"userId":"me","maxResults":1}' --format json
./gws-profile.sh finance sheets spreadsheets get --params '{"spreadsheetId":"..."}' --format json

Environment:

  • GWS_BIN
    Custom path to the gws binary.

  • GWS_PROFILES_DIR
    Base directory for profile configs. Default: ~/.config

gws-login-all.sh

Usage:

./gws-login-all.sh <profile> [profile...]

Examples:

./gws-login-all.sh work personal client-a
GWS_LOGIN_SCOPES="gmail,drive,sheets" ./gws-login-all.sh work personal
GWS_DEFAULT_PROFILES="work personal client-a" ./gws-login-all.sh

Environment:

  • GWS_LOGIN_SCOPES
    Comma-separated scopes passed to gws auth login.

  • GWS_DEFAULT_PROFILES
    Space-separated fallback profile list when no args are passed.

  • GWS_LOGIN_LOG_DIR
    Where login logs are written. Default: ~/.cache/gws-logins/<timestamp>

Security Notes

  • This repo does not store tokens.
  • This repo does not ship credentials.
  • Tokens stay in local gws profile directories created on your machine.
  • Login logs may contain OAuth callback info while a login is in progress, so keep them local.

If you share examples publicly, do not paste token contents or local callback URLs after login.

Troubleshooting

localhost refused to connect

Usually this means the gws auth login process is no longer running.

Fix:

  1. start login again
  2. keep the shell process alive
  3. open the new browser URL

Wrong account in the wrong profile

Check:

./gws-profile.sh work auth status
./gws-profile.sh personal auth status

If a profile drifted, just re-run login for that profile.

gws not found

Install it:

npm install -g @googleworkspace/cli

Or set:

export GWS_BIN=/full/path/to/gws

Why Open Source This?

Because this is one of those tiny utilities that saves real time and should not stay buried inside a private repo.

If you already use gws, this gives you multi-account support with almost no extra complexity.


Indie developer shipping MistyWayAuroraMe


Follow / DM / argue with me:

X / Twitter LinkedIn Threads Telegram

Open an issue or DM me on any of the above if you want improvements, edge-case fixes, or more wrappers around Google tooling.

License

MIT

About

Tiny wrappers for running the official Google Workspace CLI (gws) with multiple isolated accounts on one machine.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages