mirror of
https://github.com/wisdgod/cursor-api.git
synced 2025-10-07 07:31:56 +08:00
修复了一些问题
This commit is contained in:
31
tools/get-token/src/main.rs
Normal file
31
tools/get-token/src/main.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use rusqlite::Connection;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
let home_dir = env::var("HOME")
|
||||
.or_else(|_| env::var("USERPROFILE"))
|
||||
.unwrap();
|
||||
let db_path = if cfg!(target_os = "windows") {
|
||||
PathBuf::from(home_dir).join(r"AppData\Roaming\Cursor\User\globalStorage\state.vscdb")
|
||||
} else if cfg!(target_os = "linux") {
|
||||
PathBuf::from(home_dir).join(".config/Cursor/User/globalStorage/state.vscdb")
|
||||
} else {
|
||||
PathBuf::from(home_dir)
|
||||
.join("Library/Application Support/Cursor/User/globalStorage/state.vscdb")
|
||||
};
|
||||
|
||||
match Connection::open(&db_path) {
|
||||
Ok(conn) => {
|
||||
match conn.query_row(
|
||||
"SELECT value FROM ItemTable WHERE key = 'cursorAuth/accessToken'",
|
||||
[],
|
||||
|row| row.get::<_, String>(0),
|
||||
) {
|
||||
Ok(token) => println!("访问令牌: {}", token.trim()),
|
||||
Err(err) => eprintln!("获取令牌时出错: {}", err),
|
||||
}
|
||||
}
|
||||
Err(err) => eprintln!("无法打开数据库: {}", err),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user