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:
+11
-10
@@ -81,16 +81,11 @@ impl ApiClient {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut params = serde_json::json!({
|
let params = serde_json::json!({
|
||||||
"client_id": self.client_id,
|
"client_id": self.client_id,
|
||||||
"scope": "https://www.googleapis.com/auth/tasks",
|
"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
|
let resp = self
|
||||||
.client
|
.client
|
||||||
.post("https://oauth2.googleapis.com/device/code")
|
.post("https://oauth2.googleapis.com/device/code")
|
||||||
@@ -113,11 +108,17 @@ impl ApiClient {
|
|||||||
|
|
||||||
let mut msg = format!("OAuth error ({}): {} - {}", status, err_code, err_desc);
|
let mut msg = format!("OAuth error ({}): {} - {}", status, err_code, err_desc);
|
||||||
|
|
||||||
// Common fixes for known errors
|
if err_code == "invalid_client" || err_desc.contains("Invalid client") {
|
||||||
if err_desc.contains("Invalid client") || err_code == "invalid_client" {
|
|
||||||
msg.push_str(
|
msg.push_str(
|
||||||
". Check that you created a 'Desktop app' OAuth 2.0 Client ID in Google Cloud Console \
|
"\n\nPossible fixes (Google Cloud Console):\n\
|
||||||
(not 'Web application'). Also verify that Google Tasks API is enabled.",
|
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)",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user