Hi, I need help with implementing the Tauri Plugin OAuth. Currently, I am trying to enable Google login. The OAuth functionality works on the web version of my app, but now I want to implement it in my Tauri app. I am new to Tauri and currently unfamiliar with Rust, so I am feeling confused and lost. So far, I have completed the following steps:
- in Cargo.toml
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "main" }
- in main.rs
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use tauri::{command, Window};
use tauri_plugin_oauth::start;
#[command]
async fn start_server(window: Window) -> Result<u16, String> {
start(move |url| {
// Because of the unprotected localhost port, you must verify the URL here.
// Preferebly send back only the token, or nothing at all if you can handle everything else in Rust.
let _ = window.emit("redirect_uri", url);
})
.map_err(|err| err.to_string())
}
fn main() {
let sys_tray = build_system_tray();
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_oauth::init())
.system_tray(sys_tray)
.setup(|app| {
let window = app.get_window("main").unwrap();
app.global_shortcut_manager()
.register(SHORTCUT_SHOW_HIDE, move || {
show_hide_window(&window);
})
.unwrap();
Ok(())
})
.invoke_handler(tauri::generate_handler![open_settings,start_server])
.run(tauri::generate_context!())
.unwrap();
}
- In my Tauri app, I have created a functional button that can successfully redirect the user to the web for Google login. I am unsure how to implement the functionality that allows the user to return to my app and complete the login process.
thank you!