- LoginModal: 서버에서 구글 클라이언트 ID 수신 시에만 버튼 노출 - 웹/PC: Google Identity Services 렌더 버튼 - 앱(안드로이드): @capawesome/capacitor-google-sign-in 네이티브 버튼 - 네이티브/웹 모두 ID 토큰을 /api/auth/google 로 전달(aud=웹 클라이언트 ID) - auth 스토어/authApi 에 googleLogin·googleClientId 추가 - src/native/googleAuth.js 네이티브 래퍼 신규 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// 네이티브(안드로이드) 구글 로그인 래퍼 — Capacitor Credential Manager 기반.
|
||||
// 웹/Electron 에서는 GIS(웹) 방식을 쓰므로 여기선 네이티브 전용. 플러그인은 지연 import.
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
|
||||
// 네이티브 플랫폼(안드로이드 APK)에서만 네이티브 구글 로그인을 사용한다.
|
||||
export function isNativeGoogle() {
|
||||
return Capacitor.isNativePlatform()
|
||||
}
|
||||
|
||||
let initializedClientId = null
|
||||
|
||||
// 웹 클라이언트 ID(서버에서 받은 값)로 네이티브 구글 로그인을 수행하고 ID 토큰을 반환한다.
|
||||
// 반환된 ID 토큰의 aud 는 웹 클라이언트 ID 라서 백엔드 /api/auth/google 가 그대로 검증한다.
|
||||
export async function nativeGoogleIdToken(clientId) {
|
||||
const { GoogleSignIn } = await import('@capawesome/capacitor-google-sign-in')
|
||||
// initialize 는 한 번만(같은 clientId 면 재호출 생략)
|
||||
if (initializedClientId !== clientId) {
|
||||
await GoogleSignIn.initialize({ clientId })
|
||||
initializedClientId = clientId
|
||||
}
|
||||
const res = await GoogleSignIn.signIn()
|
||||
return res?.idToken || null
|
||||
}
|
||||
Reference in New Issue
Block a user