This document describes the profile system used by gwsa for managing multiple Google account identities.
Profiles allow you to switch between multiple Google accounts without re-running OAuth consent flows. Each profile stores its own credentials and metadata.
~/.config/gworkspace-access/
├── config.yaml # Active profile pointer
└── profiles/
├── default/
│ ├── user_token.json # OAuth credentials
│ └── profile.yaml # Metadata (email, scopes, validation timestamp, type)
└── work/
├── user_token.json
└── profile.yaml
(Note: Both profile types rely on Google's OAuth 2.0 Identity platform. The "type" simply denotes how the token was acquired and the JSON schema it uses under the hood.)
Standard OAuth-based profiles created via browser login.
- Created with:
gwsa profiles add <name> - Re-authenticated with:
gwsa profiles refresh <name> - Requires:
client_secrets.json(OAuth client credentials) - Stored in:
~/.config/gworkspace-access/profiles/<name>/
Profiles generating Google Cloud Application Default Credentials into the isolated vault securely.
- Created with:
gwsa profiles add <name> --type=adc --quota-project=<project> - Re-authenticated with:
gwsa profiles refresh <name> - Runs:
gcloud auth application-default logininternally, redirected to the vault - Requires: Google Cloud SDK installed
- Stored in:
~/.config/gworkspace-access/profiles/<name>/
Note: Unlike older versions of gwsa (v1.x), there is no longer a magic built-in global adc profile. ADC profiles are explicitly created and isolated exactly like standard OAuth token profiles.
| State | Description | Can Use? |
|---|---|---|
| valid | Credentials validated, ready to use | Yes |
| stale | ADC credentials changed since last validation | No |
| unvalidated | Never been validated with tokeninfo | No |
| missing | Profile directory doesn't exist | No |
| error | Token file corrupted or unreadable | No |
View profile states with gwsa profiles list:
PROFILE STATUS EMAIL VALIDATED
------------------------------------------------------------------------------
dev-adc valid dev@example.com 1h ago
* home valid user@gmail.com 2h ago
work valid worker@company.com 1d ago
------------------------------------------------------------------------------
Ready to use.
List all profiles with their status.
- Shows all configured profiles
- Marks active profile with
* - Shows validation status and timestamp
- Provides guidance if no valid/active profile
Show the currently active profile details.
Active profile: default
Type: OAuth Token
Status: valid
Email: user@gmail.com
Scopes: 6
Create a new token profile.
- For standard tokens:
gwsa profiles add <name> - For ADC tokens:
gwsa profiles add <name> --type=adc --quota-project=<project> - Opens browser for OAuth consent (or routes
gcloudlogin for ADC) - Validates credentials with tokeninfo before saving
- Atomic operation: no partial state on failure
gwsa profiles add work
gwsa profiles add my-adc --type=adc --quota-project=ai-gateway-001Re-authenticate an existing profile.
- Profile MUST already exist (use
addfor new profiles) - For token profiles: Opens browser for OAuth consent
- For ADC: Runs
gcloud auth application-default login - Validates credentials before overwriting
- Atomic operation: existing profile preserved on failure
gwsa profiles refresh default # Re-auth token profile
gwsa profiles refresh dev-adc # Re-auth ADC profileSwitch to a different profile.
- Validates credentials with tokeninfo before switching
- Blocks switching to invalid/stale/unvalidated profiles
- Use
--no-recheckto trust cached status (skip network call)
gwsa profiles use work
gwsa profiles use dev-adc --no-recheck # Trust cached statusRename a profile.
- New name must be valid (alphanumeric, hyphens, underscores)
- Atomic operation with rollback on failure
- If renaming active profile, config is updated automatically
gwsa profiles rename default personal
gwsa profiles rename work work-oldDelete a profile.
- Prompts for confirmation (use
-yto skip) - If deleting active profile, no profile becomes active
gwsa profiles delete old-profile
gwsa profiles delete temp -y # Skip confirmationOutput the raw JSON contents of a profile's token to stdout.
A utility command for integrating with external CI/scripts. It outputs the absolute file path to a profile's isolated token perfectly suited for command substitution.
export GOOGLE_APPLICATION_CREDENTIALS=$(gwsa profiles path my-adc)A legacy compatibility command. It sets the selected profile as the system-wide Application Default Credential by copying it to ~/.config/gcloud/application_default_credentials.json. Used for external tooling that does not evaluate environment variables.
gwsa profiles apply my-adcShow current configuration and profile status.
==================================================
gwsa Status
==================================================
Active Profile: default
Type: OAuth Token
Status: valid
Email: user@gmail.com
Scopes: 6
==================================================
Ready to use.
Use --check for deep validation with live API calls.
By default, profiles use calls Google's tokeninfo API to verify credentials:
- Check profile exists
- Check profile is valid (not stale/unvalidated)
- Call tokeninfo API to verify credentials work
- Update cached metadata with fresh email/scopes
- Switch active profile
With --no-recheck:
- Steps 1-2 still run (cached status must be valid)
- Steps 3-4 skipped (no network call)
- Useful for offline scenarios or scripting
Both commands validate BEFORE writing:
- Run OAuth flow (browser login)
- Call tokeninfo to validate credentials
- Only if validation succeeds: write token file and metadata
- On failure: no changes made, existing profile preserved
Symptom: "No active profile configured" on product commands
Causes:
- Fresh install, no profile selected yet
- Active profile was deleted
- Config points to non-existent profile (deleted from disk)
Recovery:
gwsa profiles list # See available profiles
gwsa profiles use <name> # Activate a valid profile
# OR
gwsa profiles add <name> # Create new profileSymptom: "Active profile is not valid" error
Causes:
- Token expired and refresh failed
- ADC credentials changed since validation
- Token file corrupted
Recovery:
gwsa profiles refresh <name> # Re-authenticate
# OR
gwsa profiles use <other> # Switch to different valid profileSymptom: "Profile not found" on profiles use or profiles refresh
Cause: Profile directory doesn't exist
Recovery:
gwsa profiles add <name> # Create the profileSymptom: Profile shows "ERROR" status in profiles list
Recovery:
gwsa profiles refresh <name> # Overwrites corrupted file
# OR
gwsa profiles delete <name> # Remove and recreate
gwsa profiles add <name>Last Resort Recovery:
rm -rf ~/.config/gworkspace-access
gwsa profiles add <name> # Start freshIf a profile folder is manually deleted while it's active:
get_active_profile()returnsNone- Treated as "no active profile"
- All commands show appropriate guidance
- User must
profiles useanother profile orprofiles adda new one
Currently allowed. Each profile maintains separate credentials. Use case: Different OAuth scopes (not yet supported) or testing.
Note: This may cause confusion. Future versions may warn or block duplicates.
Use --no-recheck to switch without network validation:
gwsa profiles use work --no-recheckThe profile must already show as "valid" in profiles list.
All product commands (mail, docs, sheets) check profile validity before executing:
- Get active profile
- If none: fail with "No active profile configured"
- Check profile status (valid/stale/unvalidated)
- If invalid: fail with status and recovery guidance
- Check required scopes
- If missing scopes: fail with guidance to refresh
This ensures fast failure with clear error messages rather than cryptic API errors.
The MCP server (gwsa-mcp) uses the same profile system:
- Tools that access Google APIs require a valid active profile
list_profilesandget_active_profilework without active profileswitch_profilevalidates before switching- Errors include hints about profile configuration
- README.md - Getting started and CLI usage
- MCP-SERVER.md - MCP server setup
- GOOGLE-API-ACCESS.md - OAuth setup and GCP project configuration