Documentation Index
Fetch the complete documentation index at: https://mintlify.com/googleworkspace/cli/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Authentication errors occur when the CLI cannot obtain or use valid credentials to access Google Workspace APIs. This guide covers common authentication problems and their solutions.Common OAuth Errors
Error: invalid_grant - Token expired or revoked
Error: invalid_grant - Token expired or revoked
Cause: Your OAuth refresh token has expired or been revoked.Solution: Re-authenticate with the CLI:If the error persists, remove existing credentials and start fresh:Note: Credentials are encrypted and stored in your OS keyring. The plaintext file at
~/.config/gws/credentials.json is a fallback.Error: invalid_client - Client authentication failed
Error: invalid_client - Client authentication failed
Cause: The OAuth client secret is missing, malformed, or doesn’t match your Google Cloud project.Solution:
- Verify
~/.config/gws/client_secret.jsonexists and contains valid OAuth client credentials - Re-download the client secret from Google Cloud Console
- Ensure you created a Desktop app OAuth client (not Web application)
- Save the downloaded JSON to
~/.config/gws/client_secret.json - Run
gws auth loginagain
Error: redirect_uri_mismatch
Error: redirect_uri_mismatch
Cause: The OAuth client is configured for the wrong redirect URI.Solution:
The CLI uses
http://localhost:PORT for OAuth callbacks. Ensure your OAuth client includes http://localhost in its authorized redirect URIs:- Go to Credentials
- Edit your OAuth 2.0 Client ID
- Add
http://localhostto Authorized redirect URIs (the CLI will use an ephemeral port) - Save and retry
gws auth login
Google hasn't verified this app
Google hasn't verified this app
Cause: Your OAuth consent screen is in testing mode and hasn’t been verified by Google.Solution: This is normal for personal projects. Click Continue to proceed.If you see scope checkboxes after clicking Continue, select all required scopes (or click Select all) before proceeding.Publishing your app: If you need to remove this warning, submit your app for OAuth verification. This is only necessary for apps used by external users.
Token Expiration Issues
Symptom: Commands Fail After Working Previously
If commands worked before but now return401 Unauthorized:
Using Pre-obtained Tokens
If you’re usingGOOGLE_WORKSPACE_CLI_TOKEN with a pre-obtained access token:
- Access tokens expire after 1 hour
- You must refresh the token before expiration
- The CLI cannot auto-refresh tokens set via environment variable
Invalid Credentials
Error: Credentials File Not Found
Error: Malformed Credentials JSON
- Remove the corrupted file:
- Re-authenticate:
Permission Issues
Error: Insufficient Permission (403)
- Your OAuth token doesn’t include the required scope
- Your account doesn’t have permission to access the resource
- You need domain-wide delegation (for service accounts)
-
Missing OAuth scopes: Re-authenticate to request additional scopes:
Select all required scopes when prompted.
- Account permissions: Verify your Google Workspace account has the necessary permissions (e.g., Admin role for Admin SDK operations).
-
Service account delegation: If using a service account, ensure domain-wide delegation is configured:
Re-authenticating
To completely reset your authentication:Debugging Tips
Check Credential Precedence
The CLI uses credentials in this order:GOOGLE_WORKSPACE_CLI_TOKEN(access token)GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE(credentials file path)- Encrypted credentials in OS keyring
~/.config/gws/credentials.json(plaintext fallback)
Verify OAuth Client Configuration
Your~/.config/gws/client_secret.json should look like:
"installed" key indicates a Desktop app OAuth client.
Test with Dry Run
Verify authentication without making actual API calls:Headless/CI Environments
Authentication errors are common in headless environments (servers, CI/CD).Export Credentials from Local Machine
-
Authenticate on a machine with a browser:
-
Export credentials:
-
On the headless machine:
Service Account Authentication
For server-to-server authentication:gws auth login required.
Still Having Issues?
If authentication continues to fail:- Check the Common Issues guide
- Review the Authentication documentation
- File an issue on GitHub with:
- The exact error message (redact sensitive info)
- Your OS and CLI version (
gws --version) - Authentication method (OAuth, service account, etc.)