Supabase Google Android 登录
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
本指南将帮助您在 Android 上将 Google Sign-In 与 Supabase 身份验证集成。假设您已经完成:
完整的实现可在 示例应用程序中找到 supabaseAuthUtils.ts 文件。 本指南解释了关键概念和如何使用它。
使用身份验证助手
标题:使用身份验证助手The authenticateWithGoogleSupabase 函数处理整个身份验证流程:
import { authenticateWithGoogleSupabase } from './supabaseAuthUtils';
const result = await authenticateWithGoogleSupabase();if (result.success) { console.log('Signed in:', result.user); // Navigate to your authenticated area} else { console.error('Error:', result.error);}如何工作
标题:如何工作有关身份验证流程的详细说明,包括 nonce 生成、 JWT 验证和 Supabase 登录,请参见《通用设置指南》中的 有关完整__CAPGO_KEEP_0__参考,请参见《通用设置指南》中的.
有关完整code参考,请参见《通用设置指南》中的 有关完整Code参考,请参见《通用设置指南》中的.
重要注意事项
重要注意事项标题令牌处理
令牌处理标题Capgo 的令牌实现遵循了 来自 React Native Google Sign In 文档的模式:
rawNonce跳转到 SupabasesignInWithIdToken()- Supabase 生成
rawNonce并与nonceDigest从 Google Sign-In 中的令牌中包含的 nonceDigest(SHA-256 哈希,16 进制编码) 跳转到nonce参数在 Google Sign-In API 中
Automatic Retry
Section titled “Automatic Retry”The implementation includes automatic retry logic:
- If JWT validation fails on first attempt, it logs out and retries once
- This handles cases where cached tokens might have incorrect nonces
- If the retry also fails, an error is returned
Troubleshooting
Section titled “Troubleshooting”If authentication fails:
- Invalid audience: Verify your Google Client IDs match in both Google Cloud Console and Supabase
- Nonce mismatch: 检查控制台日志 - 函数将自动重试,但如果需要,可以手动注销
- 令牌验证失败: 确保您使用
mode: 'online'在初始化调用中使用 idToken - 查看示例应用 __CAPGO_KEEP_0__ example app code 继续从 Supabase Google Login on Android
标题:继续从 Supabase Google Login on Android
如果您正在使用Supabase Google Login on Android 来规划身份验证和帐户流程,连接它 以计划身份验证和帐户流程,连接它 使用 @capgo/capacitor-social-login 为原生能力在使用 @capgo/capacitor-social-login, @capgo/capacitor-social-login 为实现细节在 @capgo/capacitor-social-login, @capgo/capacitor-passkey 为实现细节在 @capgo/capacitor-passkey, @capgo/capacitor-native-biometric 为实现细节在 @capgo/capacitor-native-biometric, 和 双因素认证 为实现细节在双因素认证.