메인 콘텐츠로 건너뛰기

Android에서 Supabase Google 로그인

GitHub

이 가이드는 Android에서 Google Sign-In을 Supabase 인증과 통합하는 방법을 설명합니다. 이미 다음을 완료한 것으로 가정합니다.

Implementation

Implementation

구현 예제는 예제 앱의 파일에 있습니다. 이 안내서에서는 주요 개념과 사용 방법을 설명합니다. supabaseAuthUtils.ts 인증 도우미를 사용하는 방법

Section titled “Using the Authentication Helper”

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 Builder에서 작동하는 방식 섹션을 참조하세요..

For the complete code reference, see the Complete Code Reference section in the General Setup guide.

Section titled “중요한 주의 사항”

nonce 처리

Section titled “nonce 구현은 React Native Google Sign In 문서에서 제공하는 패턴을 따릅니다.” Section titled “nonce 구현은 React Native Google Sign In 문서에서 제공하는 패턴을 따릅니다.”:

  • rawNonce Supabase로 이동합니다. signInWithIdToken()
  • Supabase는 Google Sign-In의 ID 토큰에서 SHA-256 해시를 생성합니다. rawNonce Supabase는 Google Sign-In의 ID 토큰에서 SHA-256 해시를 생성합니다. nonceDigest Google Sign-In의 ID 토큰에서 SHA-256 해시를 생성한 Supabase와 비교합니다.
  • nonceDigest Google Sign-In API에서 SHA-256 해시를 생성한 Supabase의 ID 토큰을 비교합니다. nonce 자동 재시도

JWT 검증이 첫 번째 시도에서 실패하면 로그아웃하고 다시 시도합니다.

  • 캐시된 토큰이 잘못된 nonce를 가지고 있는 경우를 처리합니다.
  • 재시도도 실패하면 오류를 반환합니다.
  • 자동 재시도

인증이 실패하면:

  • 잘못된 청중: Google Cloud Console과 Supabase에서 Google Client ID가 일치하는지 확인하십시오.
  • Nonce 일치하지 않음: 콘솔 로그를 확인하십시오 - 함수는 자동으로 다시 시도하지만 필요할 경우 수동으로 로그아웃하십시오.
  • 토큰 유효성 검사 실패: initialize 함수에 idToken을 얻기 위해 mode: 'online' 사용하십시오.
  • 예시 앱 __CAPGO_KEEP_0__ example app code 참조용

안드로이드에서 Supabase Google 로그인에서 계속하기

안드로이드에서 Supabase Google 로그인에서 계속하기

이 기능을 사용 중이라면 Supabase Google 로그인 인증 및 계정 흐름을 계획하고 Supabase Google 로그인과 연결하려면 @capgo/capacitor-social-login을 사용하여 @capgo/capacitor-social-login을 사용하여 @capgo/capacitor-social-login @capgo/capacitor-passkey @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric 구현 세부 사항에 대해 @capgo/capacitor-native-biometric 참조 두 단계 인증 구현 세부 사항에 대해 두 단계 인증 참조