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
This commit is contained in:
Ruben Rosario
2026-06-20 20:36:12 +01:00
parent df1c5f5c2a
commit 64993b127c
+11 -10
View File
@@ -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)",
);
}