From 64993b127c724e2bbe864d87e5bfaae044678b1d Mon Sep 17 00:00:00 2001 From: Ruben Rosario Date: Sat, 20 Jun 2026 20:36:12 +0100 Subject: [PATCH] fix: improve invalid_client error message with setup steps - Remove client_secret from initial /device/code request (desktop app type) - Update error message with full Google Cloud Console setup checklist: 1. Enable Google Tasks API 2. Configure OAuth consent screen (Testing mode + test users + scopes) 3. Create Desktop app OAuth client - Copy credentials exactly without extra whitespace --- src/infrastructure/api.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/infrastructure/api.rs b/src/infrastructure/api.rs index 298400b..8497988 100644 --- a/src/infrastructure/api.rs +++ b/src/infrastructure/api.rs @@ -81,16 +81,11 @@ impl ApiClient { )); } - let mut params = serde_json::json!({ + let params = serde_json::json!({ "client_id": self.client_id, "scope": "https://www.googleapis.com/auth/tasks", }); - // Some client types require client_secret in the initial request - if !self.client_secret.is_empty() { - params["client_secret"] = serde_json::Value::String(self.client_secret.clone()); - } - let resp = self .client .post("https://oauth2.googleapis.com/device/code") @@ -113,11 +108,17 @@ impl ApiClient { let mut msg = format!("OAuth error ({}): {} - {}", status, err_code, err_desc); - // Common fixes for known errors - if err_desc.contains("Invalid client") || err_code == "invalid_client" { + if err_code == "invalid_client" || err_desc.contains("Invalid client") { msg.push_str( - ". Check that you created a 'Desktop app' OAuth 2.0 Client ID in Google Cloud Console \ - (not 'Web application'). Also verify that Google Tasks API is enabled.", + "\n\nPossible fixes (Google Cloud Console):\n\ + 1. APIs & Services > Library -> Enable 'Google Tasks API'.\n\ + 2. APIs & Services > OAuth consent screen:\n\ + - Set 'Publishing status' to 'Testing'\n\ + - Add 'https://www.googleapis.com/auth/tasks' to Scopes\n\ + - Add your email under 'Test users'\n\ + 3. APIs & Services > Credentials:\n\ + - Create new OAuth 2.0 Client ID of type 'Desktop app'\n\ + - Copy the Client ID and Client Secret exactly (no extra spaces)", ); }