Quick Start
For first-time setup (creates GCP project, enables APIs, and logs you in):Prerequisites
Install gcloud CLI:First-Time Setup
Run auth setup
The This command will:
gws auth setup command automates the entire OAuth configuration process:- Create a new Google Cloud project (or use an existing one with
--project) - Enable required Google Workspace APIs
- Create an OAuth 2.0 Desktop App client
- Download the client credentials
- Trigger the OAuth login flow
Select scopes
You’ll be prompted to select OAuth scopes in an interactive picker:
- Recommended (default): Non-restricted scopes + read-only scopes
- Read Only: Only read-only scopes for enabled APIs
- Full Access: All scopes including restricted ones (may require app verification)
- Custom: Select individual scopes manually
Authorize in browser
A browser window will open with the OAuth consent screen.
- Select your Google account
- Review and approve the requested scopes
- The page will redirect to
localhostand display “Authentication complete”
Subsequent Logins
Once you’ve rungws auth setup, use gws auth login for future authentications:
~/.config/gws/client_secret.json and only requires browser authentication.
Scope Options
Security Model
Credential Encryption
Credentials are encrypted at rest using AES-256-GCM. The encryption key is stored securely:- Primary: OS Keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service)
- Fallback: Local file
~/.config/gws/.encryption_keywith0600permissions (Unix)
What’s Stored
The encrypted credentials file contains:- OAuth client ID
- OAuth client secret
- Refresh token (used to obtain new access tokens)
~/.config/gws/token_cache.json (also encrypted) and automatically refreshed when expired.
File Permissions
On Unix systems,gws automatically sets secure permissions:
- Config directory:
0700(user-only access) - Credentials files:
0600(user read/write only) - Encryption key file:
0600
Checking Authentication Status
View detailed authentication information:- Authentication method (OAuth2 or service account)
- Storage type (encrypted, plaintext, or none)
- Credential source (env var, file, or OS keyring)
- User email (if logged in)
- Granted OAuth scopes
- Enabled APIs in your GCP project
- Token validity
Exporting Credentials
For debugging or to transfer credentials to another machine:Logging Out
Remove all saved credentials and token caches:~/.config/gws/credentials.enc~/.config/gws/credentials.json(if present)~/.config/gws/token_cache.json
The OAuth client configuration (
client_secret.json) is preserved so you can run gws auth login again without repeating the full setup.Troubleshooting
”Google hasn’t verified this app” Warning
This is normal for OAuth apps in testing mode. Click Continue to proceed. To remove this warning:- Complete the OAuth app verification process
- Or add your email to the test users list in the OAuth consent screen
”restricted_client” Error
Some scopes (e.g.,cloud-platform, pubsub) require app verification or are restricted for personal accounts.
Solution:
- Use
gws auth loginwithout--full(defaults to safe scopes) - Or verify your OAuth app in Google Cloud Console
- Or use a Google Workspace account with appropriate admin permissions
Decryption Failed
If you see “Decryption failed” errors:- Credentials were created on a different machine
- The OS keyring was reset or is unavailable
- The
.encryption_keyfile was deleted
Next Steps
Headless/CI Setup
Export credentials for CI/CD environments
Manual OAuth Setup
Configure OAuth clients manually in Google Cloud Console