Skip to content

Commit 0c354f5

Browse files
committed
add rust side of example
1 parent 8b34909 commit 0c354f5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rust-version = "1.57"
88
exclude = ["/examples"]
99

1010
[dependencies]
11-
httparse = "1.7"
11+
httparse = "1"
1212
log = "0.4"
13-
tauri = { version = "1.0" }
13+
url = "2"
14+
tauri = { version = "1" }

examples/vanilla/src-tauri/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ rust-version = "1.57"
1010
[dependencies]
1111
serde_json = "1.0"
1212
serde = { version = "1.0", features = [ "derive" ] }
13-
tauri = { version = "1.0.0-rc.8", features = [ "api-all" ] }
13+
tauri = { version = "1", features = [ "api-all" ] }
1414
tauri-plugin-oauth = { path = "../../../" }
1515

1616
[build-dependencies]
17-
tauri-build = { version = "1.0.0-rc.7" }
17+
tauri-build = { version = "1" }
1818

1919
[features]
2020
default = [ "custom-protocol" ]

examples/vanilla/src-tauri/src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@
33
windows_subsystem = "windows"
44
)]
55

6+
use tauri::{command, Window};
7+
use tauri_plugin_oauth::start;
8+
9+
#[command]
10+
async fn start_server(window: Window) -> Result<u16, String> {
11+
start(None, move |url| {
12+
// Because of the unprotected localhost port, you must verify the URL here.
13+
// Preferebly send back only the token, or nothing at all if you can handle everything else in Rust.
14+
let _ = window.emit("redirect_uri", url);
15+
}).map_err(|err| err.to_string())
16+
}
17+
618
fn main() {
719
tauri::Builder::default()
8-
.plugin(tauri_plugin_oauth::init())
20+
.invoke_handler(tauri::generate_handler![start_server])
921
.run(tauri::generate_context!())
1022
.expect("error while running tauri application");
1123
}

0 commit comments

Comments
 (0)