iOS에서 Supabase Google 로그인
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함하여 설정 지시를 복사할 수 있습니다.
소개
소개 섹션이 안내서에서는 iOS에서 Google Sign-In을 Supabase 인증과 통합하는 방법을 설명합니다. 이 안내서를 사용하기 전에 다음을 완료한 것으로 가정합니다.
- __CAPGO_KEEP_0__ __CAPGO_KEEP_1__ iOS 설정
- __CAPGO_KEEP_1__ - Supabase Google Login 일반 설정 Implementation.
인증 도우미를 사용하는 방법 Using the Authentication Helper supabaseAuthUtils.ts __CAPGO_KEEP_3__
__CAPGO_KEEP_4__
__CAPGO_KEEP_5__The authenticateWithGoogleSupabase __CAPGO_KEEP_0__
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);}작동 방식
작동 방식작동 방식 섹션에서 자세한 설명을 보려면 General Setup 가이드의 중요한 주의 사항.
중요한 주의 사항
iOS Token 캐싱과 Nonce 문제iOS Nonce 캐싱 문제
iOS Nonce 캐싱 문제iOS Nonce 캐싱 문제
iOS에서 Google Sign-In은 토큰을 캐시할 수 있으므로, nonce 검증이 실패할 수 있습니다. nonce 검증이 실패하는 것을 validateJWTToken function은 이것을 자동으로 처리합니다:
- 자동 검출: function은 토큰에 있는 nonce가 예상하는 nonce와 일치하는지 확인합니다.
nonceDigest - 자동 재시도: 검증이 실패하면 Google에서 자동으로 로그아웃하고 다시 시도합니다.
- 에러 처리: 재시도가 실패하면 에러가 반환됩니다.
왜 이런 일이 발생하는가: iOS Google Sign-In SDK는 성능을 위해 토큰을 캐시합니다. 캐시된 토큰이 반환될 때, 토큰이 다른 nonce (또는 nonce가 없는 경우)로 생성되었을 수 있으므로 일치하지 않을 수 있습니다.
해결 방법: implementation은 자동으로 이것을 처리하기 위해 로그아웃하고 다시 시도하여, Google이 올바른 nonce와 함께 새로운 토큰을 생성하도록 강제합니다.
자동 작업 우회 (자동 재시도가 작동하지 않는 경우):
// Logout first to clear cached tokensawait SocialLogin.logout({ provider: 'google' });
// Then authenticateconst result = await authenticateWithGoogleSupabase();이것은 올바른 nonce와 함께 새로운 토큰을 얻는 것을 보장합니다.
code의 전체 참조를 보려면 Code의 전체 참조를 보려면 일반 설정 가이드의 '일반 설정 가이드' 섹션을 참조하십시오..
중요한 주의 사항
'중요한 주의 사항'이라는 제목을 가진 섹션nonce 처리
'nonce 처리'라는 제목을 가진 섹션nonce 구현은 React Native Google Sign In 문서에서 설명하는 패턴을 따릅니다. __CAPGO_KEEP_0__의 전체 참조를 보려면 일반 설정 가이드의 '일반 설정 가이드' 섹션을 참조하십시오.:
rawNonceSupabase로 이동합니다.signInWithIdToken()- Supabase는 Google Sign-In의 ID 토큰에서 SHA-256 해시를 생성합니다.
rawNonce해시를 Supabase의nonceDigest해시와 비교합니다. nonceDigestGoogle Sign-In의 ID 토큰에서 SHA-256 해시를 생성합니다.nonce(SHA-256 해시, 16진수 인코딩) Supabase로 이동합니다.
자동 재시도 메커니즘
자동 재시도 메커니즘The authenticateWithGoogleSupabase 함수에는 retry 파라미터가 있습니다.
- 첫 번째 호출(
retry=falseIf validation fails, automatically logs out and retries once - Retry call (
retry=trueIf validation fails again, immediately returns an error
This handles the iOS token caching issue automatically.
Troubleshooting
Section titled “Troubleshooting”If authentication fails:
- Nonce mismatch: The function automatically retries - check console logs for details. If it persists, manually logout first
- Invalid audience: Verify your Google Client IDs match in both Google Cloud Console and Supabase (both iOS and Web client IDs)
- Token validation fails: __CAPGO_KEEP_0__을 사용 중인지 확인하세요.
mode: 'online'in the initialize call to get an idToken - Info.plist 설정: Info.plist에 올바른 URL schemes과 GIDClientID가 있는지 확인하세요.
- Review the 예시 앱 code 참고로
iOS에서 Supabase Google Login을 계속 진행하세요.
제목: iOS에서 Supabase Google Login을 계속 진행하세요.iOS에서 Supabase Google Login을 사용 중이라면 Supabase Google Login on iOS를 사용하여 인증 및 계정 흐름을 계획하고 연결하세요. @capgo/capacitor-social-login Using @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의 구현 세부 사항 Two-factor authentication Two-factor authentication의 구현 세부 사항