feat(android): Google OAuth via system browser + deep link for Android
Background: Google blocks OAuth in embedded WebView (403 disallowed_useragent). Solution: open Google login in the Android system browser, then deep-link back to the Tauri app via custom scheme after callback. Changes: - Tauri: add tauri-plugin-opener + tauri-plugin-deep-link to Cargo.toml - Tauri: register plugins in lib.rs, add capabilities - Web: auth-form.tsx Google button uses openUrl() via @tauri-apps/plugin-opener on Tauri (opens in system browser), falls back to window.location.href - Web: add lib/tauri.ts for isTauri() detection + lazy opens - API: /auth/google accepts ?platform=tauri → encodes into OAuth state param - API: /auth/google/callback decodes state → if tauri, renders HTML page that deep-links back via zeavisedu:// scheme; if web, 302 redirect - Android: patch script adds deep link intent filter for zeavisedu:// scheme Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Patches the generated AndroidManifest.xml to add CAMERA permission.
|
||||
# Patches the generated AndroidManifest.xml with:
|
||||
# 1. CAMERA permission
|
||||
# 2. Deep link intent filter (zeavisedu:// scheme) for Google OAuth return
|
||||
# Run after `tauri android init` to apply.
|
||||
set -euo pipefail
|
||||
|
||||
@@ -10,11 +12,34 @@ if [ ! -f "$MANIFEST" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -q 'android.permission.CAMERA' "$MANIFEST"; then
|
||||
echo "CAMERA permission already present in AndroidManifest.xml"
|
||||
exit 0
|
||||
# ── CAMERA permission ──────────────────────────────────────────────────
|
||||
|
||||
if ! grep -q 'android.permission.CAMERA' "$MANIFEST"; then
|
||||
echo "Adding CAMERA permission to AndroidManifest.xml..."
|
||||
sed -i 's|<uses-permission android:name="android.permission.INTERNET" />|<uses-permission android:name="android.permission.INTERNET" />\n <uses-permission android:name="android.permission.CAMERA" />\n <uses-feature android:name="android.hardware.camera" android:required="false" />\n <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />|' "$MANIFEST"
|
||||
else
|
||||
echo "CAMERA permission already present."
|
||||
fi
|
||||
|
||||
echo "Adding CAMERA permission to AndroidManifest.xml..."
|
||||
sed -i 's|<uses-permission android:name="android.permission.INTERNET" />|<uses-permission android:name="android.permission.INTERNET" />\n <uses-permission android:name="android.permission.CAMERA" />\n <uses-feature android:name="android.hardware.camera" android:required="false" />\n <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />|' "$MANIFEST"
|
||||
echo "Done."
|
||||
# ── Deep link intent filter ────────────────────────────────────────────
|
||||
# Allows the app to receive zeavisedu:// scheme URLs from the system browser
|
||||
# (used after Google OAuth completes in external browser on Android)
|
||||
|
||||
DEEP_LINK_FILTER='<!-- Deep link for Google OAuth return from system browser -->\
|
||||
<intent-filter android:autoVerify="true">\
|
||||
<action android:name="android.intent.action.VIEW" />\
|
||||
<category android:name="android.intent.category.DEFAULT" />\
|
||||
<category android:name="android.intent.category.BROWSABLE" />\
|
||||
<data android:scheme="zeavisedu" />\
|
||||
</intent-filter>'
|
||||
|
||||
if grep -q 'android:scheme="zeavisedu"' "$MANIFEST"; then
|
||||
echo "Deep link intent filter already present."
|
||||
else
|
||||
echo "Adding deep link intent filter to AndroidManifest.xml..."
|
||||
# Insert before the closing </activity> tag of MainActivity
|
||||
sed -i "s|</activity>|${DEEP_LINK_FILTER}\n </activity>|" "$MANIFEST"
|
||||
echo "Deep link intent filter added."
|
||||
fi
|
||||
|
||||
echo "AndroidManifest patched successfully."
|
||||
|
||||
Reference in New Issue
Block a user