__CAPGO_KEEP_1__
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
소개
소개In this guide, you will learn how to setup Google Login with Capgo Social Login. You will need the following in order to setup Google Login:
- 이 가이드에서 Google 로그인을 설정하는 방법을 배울 것입니다. __CAPGO_KEEP_0__ Social Login을 사용하기 위해 다음이 필요합니다:
Google 계정
일반 설정이 부분에서 Google이 표시하는 로그인 화면을 설정하겠습니다.
- 다음으로 이동하세요 __CAPGO_KEEP_0__
- __CAPGO_KEEP_1__
- __CAPGO_KEEP_3__ __CAPGO_KEEP_4__.
- __CAPGO_KEEP_5__
New project
- __CAPGO_KEEP_7__
Create
- __CAPGO_KEEP_9__
- __CAPGO_KEEP_5__
- __CAPGO_KEEP_11__
OAuth consent screen-
__CAPGO_KEEP_0__을 클릭하세요.
-
__CAPGO_KEEP_1__을(를) 입력하세요.
OAuth consent screen__CAPGO_KEEP_2__을(를) 클릭하세요.
-
동의 화면을 구성하세요.
외부 및 내부 옵션을 포함하는 OAuth 동의 화면 __CAPGO_KEEP_0__ 유형 선택 화면.
create
-
- 앱 정보를 입력하세요
-
먼저
App Information
- 이메일 주소를 입력하세요
App Name - 입력하세요
user support email
-
당신은 CAN 앱 로고를 추가할 수 있습니다.
-
당신은 SHOULD 인증된 도메인 필드가 있는 앱 도메인 구성 섹션을 구성해야 합니다.
App domain
-
You HAVE TO provide the developer’s email
-
Configure the scopes
save and continue
- 이메일 주소를 입력하세요
-
- Configure the scopes
-
Click on
add or remove scopes
-
다음 범위를 선택하고 클릭하세요.
update
-
클릭
save and continue
-
- 테스트 사용자 추가
- 테스트 사용자 섹션의 추가 사용자 버튼 클릭
add users
- 테스트 사용자 입력란과 추가 버튼
add
- 테스트 사용자 화면의 저장 및 계속 버튼
save and continue
- 테스트 사용자 섹션의 추가 사용자 버튼 클릭
- Click
back to dashboard
- 제출을 위해 앱을 확인하세요
온라인 접근과 오프라인 접근의 차이점
온라인 접근과 오프라인 접근의 차이점Google 로그인과 Capacitor을 사용하는 방법은 여러 가지입니다. 두 가지 방법의 차이점을 요약한 표를 아래에示합니다.
| 온라인 접근 | 오프라인 접근 | |
|---|---|---|
| 백엔드가 필요합니다 | ❌ | ✅ |
| 장기 유지 액세스 토큰 | ❌ | ✅ |
| 쉬운 설정 | ✅ | ❌ |
액세스하고
-
리프레시 토큰을
백엔드에서
-
리프레시하는
방법을
-
__CAPGO_KEEP_0__
__CAPGO_KEEP_0__
-
__CAPGO_KEEP_0__
__CAPGO_KEEP_0__
온라인 접근을 위한 예시 백엔드
온라인 접근을 위한 예시 백엔드이 부분의 튜토리얼에서, 사용자의 백엔드에서 인증을 확인하는 방법을 보여드리겠습니다.
이 예시는 매우 단순하고, 다음 기술을 기반으로 하겠습니다:
이 예시의 code를 찾을 수 있습니다. __CAPGO_KEEP_0__
__CAPGO_KEEP_1__
__CAPGO_KEEP_0__ GET __CAPGO_KEEP_0__ https://www.googleapis.com/oauth2/v3/tokeninfo __CAPGO_KEEP_0__
__CAPGO_KEEP_0__
API __CAPGO_KEEP_0____CAPGO_KEEP_0__
__CAPGO_KEEP_0__
offline 액세스 사용하기offline 액세스를 사용하려면 다음이 필요합니다.
- HTTP 서버
이 예제에서 offline 액세스를 제공하기 위해 사용하는 기술은 다음과 같습니다.
-
LowDb (간단한 데이터베이스)
이 예제의 code는 여기서 찾을 수 있습니다.
code의 클라이언트는 다음과 같습니다.
import { Capacitor } from '@capacitor/core';import { GoogleLoginOfflineResponse, SocialLogin } from '@capgo/capacitor-social-login';import { usePopoutStore } from '@/popoutStore'; // <-- specific to my app
const baseURL = "[redacted]";
async function fullLogin() { await SocialLogin.initialize({ google: { webClientId: '[redacted]', iOSClientId: '[redacted]', iOSServerClientId: 'The same value as webClientId', mode: 'offline' // <-- important } }) const response = await SocialLogin.login({ provider: 'google', options: { forceRefreshToken: true // <-- important } })
if (response.provider === 'google') { const result = response.result as GoogleLoginOfflineResponse const res = await fetch(`${baseURL}/auth/google_offline`, { headers: { "Content-Type": "application/json" }, body: JSON.stringify({ serverAuthCode: result.serverAuthCode, platform: Capacitor.getPlatform() }), method: "POST" })
if (res.status !== 200) { popoutStore.popout("Full google login failed", "check console"); return }
const { jwt } = await res.json(); const userinfo = await fetch(`${baseURL}/auth/get_google_user`, { headers: { Authorization: `Bearer ${jwt}` } }) if (userinfo.status !== 200) { popoutStore.popout("Full google (userinfo) login failed", "check console"); return } popoutStore.popout("userinfo res", await userinfo.text()); }}__CAPGO_KEEP_0__에서 호출되지 않는다는 것을 주목하십시오: 앱에서 호출되지 않는다는 것입니다. 그 이유는 Google 오프라인 모드에서, 백엔드가 SocialLogin.refresh() refresh token을 안전하게 저장하기 때문입니다. serverAuthCode Google 로그인 설정에서 계속하기
__CAPGO_KEEP_0__에서 __CAPGO_KEEP_1__-social-login을 사용하는 경우
Google 로그인 설정을 사용하여 인증 및 계정 흐름을 계획하고__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login을 사용하여 네이티브 기능을 연결합니다. __CAPGO_KEEP_0__는 __CAPGO_KEEP_1__-social-login을 사용하는 네이티브 기능입니다. __CAPGO_KEEP_0__는 __CAPGO_KEEP_1__-social-login을 사용하는 네이티브 기능입니다. 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, 두 단계 인증 구현 세부 사항에 대한 두 단계 인증