This commit is contained in:
Yukino_fox
2026-04-11 12:13:34 +08:00
26 changed files with 3160 additions and 696 deletions
+15 -6
View File
@@ -335,7 +335,10 @@ pub async fn oauth_get_authorization_url(
use rand::Rng;
let mut rng = rand::thread_rng();
let random_bytes: Vec<u8> = (0..32).map(|_| rng.gen()).collect();
base64::Engine::encode(&base64::engine::general_purpose::URL_SAFE_NO_PAD, &random_bytes)
base64::Engine::encode(
&base64::engine::general_purpose::URL_SAFE_NO_PAD,
&random_bytes,
)
});
let url = format!(
@@ -345,7 +348,10 @@ pub async fn oauth_get_authorization_url(
urlencoding::encode(&state)
);
Ok(IpcResponse::success(OAuthAuthorizationUrlResponse { url, state }))
Ok(IpcResponse::success(OAuthAuthorizationUrlResponse {
url,
state,
}))
}
#[tauri::command]
@@ -367,9 +373,9 @@ pub async fn oauth_exchange_code(
("client_secret", &platform_secret),
("redirect_uri", &callback_url),
];
println!("[OAuth] 请求参数:{:?}", params);
let response = client
.post("https://sectl.top/api/oauth/token")
.form(&params)
@@ -378,8 +384,11 @@ pub async fn oauth_exchange_code(
.map_err(|e| format!("Request failed: {}", e))?;
println!("[OAuth] 响应状态:{}", response.status());
let response_text = response.text().await.map_err(|e| format!("Failed to read response: {}", e))?;
let response_text = response
.text()
.await
.map_err(|e| format!("Failed to read response: {}", e))?;
println!("[OAuth] 响应内容:{}", response_text);
if !response_text.is_empty() && response_text.contains("error") {