gws auth setupcannot automate project/client creation- You want explicit control over the OAuth client configuration
- You’re using a shared GCP project with existing OAuth clients
- You need to configure the OAuth consent screen with specific branding
Prerequisites
- A Google Cloud project with billing enabled
- Owner or Editor permissions on the project
- Access to the Google Cloud Console
Setup Steps
Enable required APIs
Navigate to the API Library and enable:
- Google Drive API
- Gmail API
- Google Calendar API
- Google Sheets API
- Google Docs API
- Google Slides API
- (Any other Workspace APIs you need)
gcloud:Configure OAuth consent screen
Open the OAuth consent screen configuration:Replace
YOUR_PROJECT_ID with your actual project ID.Configure:- User Type: External (unless you have a Google Workspace org)
- App name:
gws CLI(or your preferred name) - User support email: Your email
- Developer contact email: Your email
For personal projects, select External and keep the app in “Testing” mode. This allows up to 100 test users without requiring app verification.
Add test users (if in testing mode)
If your app is in Testing mode, add your Google account email to the test users list:
- Scroll to Test users
- Click Add Users
- Enter your email address
- Click Save
Create OAuth client ID
Navigate to the Credentials page:Create credentials:
- Click Create Credentials → OAuth client ID
- Application type: Desktop app
- Name:
gws CLI(or your preferred name) - Click Create
The “Desktop app” type is required for
gws to use the http://localhost redirect flow.Download client secret JSON
After creating the OAuth client:
- Click the Download icon (⬇) next to your newly created client
- Save the file as
client_secret.json
Place client secret file
Move the downloaded file to the The file must be located at:
gws config directory:Alternative: Environment Variables
Instead of placing theclient_secret.json file, you can provide credentials via environment variables:
File Locations
| File | Path | Purpose |
|---|---|---|
| OAuth client config | ~/.config/gws/client_secret.json | Client ID and secret (plaintext) |
| Encrypted credentials | ~/.config/gws/credentials.enc | Refresh token (encrypted) |
| Token cache | ~/.config/gws/token_cache.json | Access tokens (encrypted, auto-refreshed) |
| Encryption key | ~/.config/gws/.encryption_key | AES-256 key (fallback if OS keyring unavailable) |
Credential Precedence
Whengws auth login looks for OAuth client credentials, it checks in this order:
GOOGLE_WORKSPACE_CLI_CLIENT_IDandGOOGLE_WORKSPACE_CLI_CLIENT_SECRETenv vars~/.config/gws/client_secret.jsonfile
Scopes Configuration
By default,gws auth login requests these scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/spreadsheetshttps://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/calendarhttps://www.googleapis.com/auth/documentshttps://www.googleapis.com/auth/presentationshttps://www.googleapis.com/auth/tasks
Verifying the Setup
Check that authentication is working:Troubleshooting
”No OAuth client configured” Error
This meansgws can’t find client_secret.json. Verify:
”Invalid client_secret.json format” Error
The file must match the Google Cloud Console download format with aninstalled wrapper object. Verify:
null, re-download the file from the Console.
”redirect_uri_mismatch” Error
The OAuth client must be type Desktop app with redirect URIhttp://localhost. Verify in the Cloud Console:
- Go to Credentials
- Click your OAuth client
- Check Application type is “Desktop app”
- Check Authorized redirect URIs includes
http://localhost
Security Considerations
- Never commit
client_secret.jsonto version control - Add
~/.config/gws/to.gitignoreif working in a repo - Rotate the client secret if it’s ever exposed
credentials.enc.
Next Steps
Interactive Auth
Learn about the automated setup flow
Headless/CI Setup
Use these credentials in CI/CD environments