tauri-plugin-social-auth
Native social sign-in plugin for Tauri mobile applications.
tauri-plugin-social-auth provides one Rust crate with three plugin commands:
plugin:google-auth|signIn-> returns GoogleidTokenplugin:vk-auth|signIn-> returns VKaccessTokenplugin:yandex-auth|signIn-> returns YandexaccessToken
| Platform | Supported |
|---|---|
| Linux | - |
| Windows | - |
| macOS | - |
| Android | ✓ |
| iOS | - |
Install
This plugin requires Rust 1.77.2+.
Add dependency in src-tauri/Cargo.toml:
[]
= "0.1"
Setup
1. Register plugins in Rust
src-tauri/src/lib.rs:
2. Declare plugin commands for capability generation
src-tauri/build.rs:
3. Android configuration
- Min SDK:
26. - Set
GOOGLE_SERVER_CLIENT_IDin appBuildConfig(used by Google Sign-In command). - Plugin already declares
android.permission.INTERNET.
Example (android/app/build.gradle.kts):
android {
defaultConfig {
val googleServerClientId = System.getenv("GOOGLE_SERVER_CLIENT_ID") ?: ""
buildConfigField("String", "GOOGLE_SERVER_CLIENT_ID", "\"$googleServerClientId\"")
}
}
JavaScript usage
No separate guest JS package is required.
import { invoke } from "@tauri-apps/api/core";
export async function signInGoogle() {
return invoke<{ idToken: string }>("plugin:google-auth|signIn");
}
export async function signInVk(theme?: "light" | "dark") {
return invoke<{ accessToken: string }>("plugin:vk-auth|signIn", theme ? { theme } : undefined);
}
export async function signInYandex() {
return invoke<{ accessToken: string }>("plugin:yandex-auth|signIn");
}
Command contracts
Google:
- Command:
plugin:google-auth|signIn - Args: none
- Success:
{ idToken: string }
VK:
- Command:
plugin:vk-auth|signIn - Args:
{ theme?: "light" | "dark" } - Success:
{ accessToken: string }
Yandex:
- Command:
plugin:yandex-auth|signIn - Args: none
- Success:
{ accessToken: string }
Error codes
Canceled:
GOOGLE_AUTH_CANCELEDVK_AUTH_CANCELEDYANDEX_AUTH_CANCELED
Init/config/runtime:
GOOGLE_SIGN_IN_INIT_FAILEDVK_AUTH_INIT_FAILEDYANDEX_AUTH_INIT_FAILEDGOOGLE_SIGN_IN_FAILEDVK_AUTH_FAILEDYANDEX_AUTH_FAILED
Notes
This plugin was fully developed with the help of AI.
License
MIT or Apache-2.0, where applicable.