내용으로

__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이 표시하는 로그인 화면을 설정하겠습니다.

  1. 다음으로 이동하세요 __CAPGO_KEEP_0__
  2. __CAPGO_KEEP_1__ __CAPGO_KEEP_2__
  3. __CAPGO_KEEP_3__ __CAPGO_KEEP_4__.
    1. __CAPGO_KEEP_5__ New project __CAPGO_KEEP_6__
    2. __CAPGO_KEEP_7__ Create __CAPGO_KEEP_8__
    3. __CAPGO_KEEP_9__ __CAPGO_KEEP_10__
  4. __CAPGO_KEEP_11__ OAuth consent screen
    1. __CAPGO_KEEP_0__을 클릭하세요.

      __CAPGO_KEEP_0__ 검색 바
    2. __CAPGO_KEEP_1__을(를) 입력하세요. OAuth consent screen __CAPGO_KEEP_2__을(를) 클릭하세요.

      OAuth 동의 화면 옵션을 보여주는 검색 결과
    3. 동의 화면을 구성하세요.

      외부 및 내부 옵션을 포함하는 OAuth 동의 화면 __CAPGO_KEEP_0__ 유형 선택 화면. create

      __CAPGO_KEEP_0__은(는) __CAPGO_KEEP_1__을(를) 사용합니다.
  5. 앱 정보를 입력하세요
    1. 먼저 App Information

      앱 정보 섹션에 앱 이름과 사용자 지원 이메일 필드를 보여줍니다
      • 이메일 주소를 입력하세요 App Name
      • 입력하세요 user support email
      1. 당신은 CAN 앱 로고를 추가할 수 있습니다.

        OAuth 동의 화면의 앱 로고 업로드 섹션
      2. 당신은 SHOULD 인증된 도메인 필드가 있는 앱 도메인 구성 섹션을 구성해야 합니다. App domain

        주의
      3. You HAVE TO provide the developer’s email

        Click on
      4. Configure the scopes save and continue

        Click on
  6. Configure the scopes
    1. Click on add or remove scopes

      범위 설정 화면의 범위 추가/제거 버튼
    2. 다음 범위를 선택하고 클릭하세요. update

      이메일 및 프로필 범위가 선택된 범위 선택 대화 상자
    3. 클릭 save and continue

      범위 설정 화면의 저장 및 계속 버튼
  7. 테스트 사용자 추가
    1. 테스트 사용자 섹션의 추가 사용자 버튼 클릭 add users Google 이메일을 입력하고 Enter를 누르세요. 그리고 클릭
    2. 테스트 사용자 입력란과 추가 버튼 add 클릭
    3. 테스트 사용자 화면의 저장 및 계속 버튼 save and continue __CAPGO_KEEP_0__
  8. Click back to dashboard completion 페이지 하단의 대시보드 버튼
  9. 제출을 위해 앱을 확인하세요

온라인 접근과 오프라인 접근의 차이점

온라인 접근과 오프라인 접근의 차이점

Google 로그인과 Capacitor을 사용하는 방법은 여러 가지입니다. 두 가지 방법의 차이점을 요약한 표를 아래에示합니다.

온라인 접근오프라인 접근
백엔드가 필요합니다
장기 유지 액세스 토큰
쉬운 설정

액세스하고

  1. 리프레시 토큰을

    백엔드에서

  2. 리프레시하는

    방법을

  3. __CAPGO_KEEP_0__

    __CAPGO_KEEP_0__

  4. __CAPGO_KEEP_0__

    __CAPGO_KEEP_0__

온라인 접근을 위한 예시 백엔드

온라인 접근을 위한 예시 백엔드

이 부분의 튜토리얼에서, 사용자의 백엔드에서 인증을 확인하는 방법을 보여드리겠습니다.

이 예시는 매우 단순하고, 다음 기술을 기반으로 하겠습니다:

이 예시의 code를 찾을 수 있습니다. __CAPGO_KEEP_0__

__CAPGO_KEEP_1__

VS Code showing Google authentication code that verifies tokens

__CAPGO_KEEP_0__ GET __CAPGO_KEEP_0__ https://www.googleapis.com/oauth2/v3/tokeninfo __CAPGO_KEEP_0__

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

API __CAPGO_KEEP_0____CAPGO_KEEP_0__

offline 액세스를 사용하려면 다음이 필요합니다.

  • HTTP 서버

이 예제에서 offline 액세스를 제공하기 위해 사용하는 기술은 다음과 같습니다.

이 예제의 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, 두 단계 인증 구현 세부 사항에 대한 두 단계 인증