Skip to content

401: Failed to parse authorized user credentials on all API calls after successful gws auth login (v0.4.3, macOS) #151

@raludi

Description

@raludi

Description

After a successful gws auth login, all API calls fail with:

{
"error": {
"code": 401,
"message": "Gmail auth failed: Failed to parse authorized user credentials",
"reason": "authError"
}
}

Environment

  • gws version: 0.4.3
  • OS: macOS (Darwin 25.3.0)
  • Encryption: AES-256-GCM with local .encryption_key

Steps to Reproduce

  1. gws auth setup → success
  2. gws auth login → completes OAuth flow, saves credentials.enc
  3. gws auth status → shows token_valid: true, correct scopes, encryption_valid: true
  4. gws gmail +triage → fails with 401
  5. gws gmail users messages list --params '{"userId": "me"}' → also fails with 401

Investigation

  • gws auth export works and shows (masked) credentials — confirming the encrypted file can be decrypted.
  • Manually decrypting credentials.enc using the .encryption_key with Node.js crypto.createDecipheriv('aes-256-gcm', ...) produces valid JSON with all fields (client_id, client_secret, refresh_token, type).
  • Exchanging the decrypted refresh_token for an access token via curl to https://oauth2.googleapis.com/token succeeds.
  • Using GOOGLE_WORKSPACE_CLI_TOKEN=<access_token> gws gmail +triage works correctly.

This confirms the credentials are valid but gws fails to parse them during API call authentication, despite successfully decrypting them during auth export and auth status.

Attempted Workarounds

  • Deleted .encryption_key + credentials.enc and re-ran gws auth login → same error
  • Exported credentials to a plain JSON file and set GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE → fails with Failed to get token
  • Setting GOOGLE_WORKSPACE_CLI_TOKEN with a manually obtained access token → works (but tokens expire after 1 hour)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions