메인 콘텐츠로 건너뛰기

Google Auth 마이그레이션을 @capgo/social-login으로 진행하세요.

GitHub

이 가이드는 @codetrix-studio/capacitor-google-auth 에서 @capgo/capacitor-social-login, ensuring a smooth transition and improved authentication experience. The new plugin unifies multiple social authentication providers under a single, consistent API.

, 완벽한 마이그레이션 단계를 제공하여 smooth한 전환 및 향상된 인증 경험을 보장합니다. 새로운 플러그인은 여러 소셜 인증 제공자를 단일, 일관된 __CAPGO_KEEP_0__ 하위로 통합합니다.

설치
  1. __CAPGO_KEEP_0__

    이 섹션에서는
    npm uninstall @codetrix-studio/capacitor-google-auth
  2. 복사

    __CAPGO_KEEP_0__를 설치합니다.
    npm install @capgo/capacitor-social-login
    npx cap sync

Google Auth 설정에서 중요한 변경 사항

Google Auth 설정에서 중요한 변경 사항

웹 클라이언트 ID 요구 사항

웹 클라이언트 ID 요구 사항

중요한 변경 사항: 업데이트된 플러그인은 모든 플랫폼에서 웹 클라이언트 ID를 사용해야 합니다.

필요한 항목

  1. Google Cloud Console에서 웹 클라이언트 ID를 만드는 방법인증 정보를 얻는 방법)
  2. 이 웹 클라이언트 ID를 모든 플랫폼에서 사용하세요 webClientId Android의 경우, SHA1과 함께 Android 클라이언트 ID를 만드는 것이 필요합니다. 그러나 이 토큰은 사용되지 않습니다 (
  3. 웹 클라이언트 ID를 만드는 방법안드로이드 설정 가이드)

변경 사항 가져오기

변경 사항 가져오기 제목
import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
import { SocialLogin } from '@capgo/capacitor-social-login';

구글 구성이 중첩된 GoogleAuth.initialize() 구글 구성이 중첩된 설정으로 변환됩니다: SocialLogin.initialize() 클립보드 복사

GoogleAuth.initialize({
clientId: 'CLIENT_ID.apps.googleusercontent.com',
scopes: ['profile', 'email'],
grantOfflineAccess: true,
});
await SocialLogin.initialize({
google: {
webClientId: 'WEB_CLIENT_ID.apps.googleusercontent.com', // Use Web Client ID for all platforms
iOSClientId: 'IOS_CLIENT_ID', // for iOS
mode: 'offline' // replaces grantOfflineAccess
}
});

로그인 방법이 GoogleAuth.signIn() 에서 SocialLogin.login()

const user = await GoogleAuth.signIn();
const res = await SocialLogin.login({
provider: 'google',
options: {
scopes: ['email', 'profile'],
forceRefreshToken: true // if you need refresh token
}
});

플랫폼별 변경 사항

플랫폼별 변경 사항 섹션

안드로이드

안드로이드 섹션
  1. Capgo를 업데이트하여 MainActivity.java (Capgo를 업데이트하여 안드로이드를 완전히 설정하세요):
import ee.forgr.capacitor.social.login.GoogleProvider;
import ee.forgr.capacitor.social.login.SocialLoginPlugin;
import ee.forgr.capacitor.social.login.ModifiedMainActivityForSocialLoginPlugin;
import com.getcapacitor.PluginHandle;
import com.getcapacitor.Plugin;
import android.content.Intent;
import android.util.Log;
public class MainActivity extends BridgeActivity {
public class MainActivity extends BridgeActivity implements ModifiedMainActivityForSocialLoginPlugin {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode >= GoogleProvider.REQUEST_AUTHORIZE_GOOGLE_MIN && requestCode < GoogleProvider.REQUEST_AUTHORIZE_GOOGLE_MAX) {
PluginHandle pluginHandle = getBridge().getPlugin("SocialLogin");
if (pluginHandle == null) {
Log.i("Google Activity Result", "SocialLogin login handle is null");
return;
}
Plugin plugin = pluginHandle.getInstance();
if (!(plugin instanceof SocialLoginPlugin)) {
Log.i("Google Activity Result", "SocialLogin plugin instance is not SocialLoginPlugin");
return;
}
((SocialLoginPlugin) plugin).handleGoogleLoginIntent(requestCode, data);
}
}
public void IHaveModifiedTheMainActivityForTheUseWithSocialLoginPlugin() {}
}
  1. AppDelegate.swift (에서 큰 변화가 필요하지 않습니다 (iOS 설정 가이드)

  2. __CAPGO_KEEP_1__에서 __CAPGO_KEEP_2__를 업데이트하세요. capacitor.config.json__CAPGO_KEEP_3__는 새로운 플러그인에서 사용하지 않습니다:

{
"plugins": {
"GoogleAuth": {
"scopes": ["profile", "email"],
"serverClientId": "xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"forceCodeForRefreshToken": true
}
}
  1. Google Sign-In 메타 태그를 제거하세요. index.html __CAPGO_KEEP_4__ 사용 중이면:
<meta name="google-signin-client_id" content="{your client id here}" />
<meta name="google-signin-scope" content="profile email" />

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

__CAPGO_KEEP_3__

interface GoogleLoginResponse {
provider: 'google';
result: {
accessToken: {
token: string;
expires: string;
// ... other token fields
} | null;
idToken: string | null;
profile: {
email: string | null;
familyName: string | null;
givenName: string | null;
id: string | null;
name: string | null;
imageUrl: string | null;
};
};
}

__CAPGO_KEEP_4__

  • __CAPGO_KEEP_5____CAPGO_KEEP_6__'google')
  • __CAPGO_KEEP_7____CAPGO_KEEP_8__
  • __CAPGO_KEEP_9____CAPGO_KEEP_10__
  • 프로필: 이메일, 이름, 이미지 URL 포함한 사용자 프로필 정보

새로운 패키지는 Google 이외의 여러 가지 소셜 인증 제공자도 지원합니다:

이 통합 접근 방식은:

  • 모든 제공자에서 일관적인 API
  • 타입스크립트 지원 향상
  • 오류 처리 향상
  • 활발한 유지 보수 및 커뮤니티 지원

Check the main documentation for detailed setup instructions for these additional providers.

Keep going from Google Auth Migration to @capgo/social-login

Section titled “Keep going from Google Auth Migration to @capgo/social-login”

If you are using Google Auth Migration to @capgo/social-login to plan authentication and account flows, connect it with Using @capgo/capacitor-social-login for the native capability in Using @capgo/capacitor-social-login, @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, @capgo/capacitor-passkey capgo/capacitor-passkey 구현 세부 사항을 참조하십시오. @capgo/capacitor-native-biometric capgo/capacitor-native-biometric 구현 세부 사항을 참조하십시오, 그리고 두 단계 인증 두 단계 인증 구현 세부 사항을 참조하십시오.