mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 03:09:50 +08:00
fix(oauth): 兼容 Kiro device token 的 snake_case 字段并保留 error 响应体
- device poll 同时接受 accessToken/access_token、refreshToken/refresh_token、expiresIn/expires_in - post_kiro_device_oidc_json 在解析失败响应时保留完整 JSON 并附加 _error 标记, 避免丢失 authorization_pending 等详细信息 - 补充 authorization_pending 时 device session 保持 pending 状态的测试
This commit is contained in:
@@ -578,12 +578,25 @@ async fn post_kiro_device_oidc_json(
|
||||
let status = response.status;
|
||||
let body_text = response.body_text;
|
||||
Ok(
|
||||
serde_json::from_str::<serde_json::Value>(&body_text).unwrap_or_else(|_| {
|
||||
json!({
|
||||
match serde_json::from_str::<serde_json::Value>(&body_text) {
|
||||
Ok(mut payload) => {
|
||||
if !status.is_success() {
|
||||
if let Some(object) = payload.as_object_mut() {
|
||||
object.insert("_error".to_string(), json!(true));
|
||||
} else {
|
||||
payload = json!({
|
||||
"_error": true,
|
||||
"data": payload,
|
||||
});
|
||||
}
|
||||
}
|
||||
payload
|
||||
}
|
||||
Err(_) => json!({
|
||||
"_error": !status.is_success(),
|
||||
"error": body_text.trim(),
|
||||
})
|
||||
}),
|
||||
}),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user