Skip to content

Getting Started

  1. 패키지를 설치하세요.

    터미널 창
    bun add @capgo/capacitor-social-login
  2. 자연 프로젝트와 Sync

    터미널 창
    bunx cap sync
  3. 앱 시작 시 초기화

    import { SocialLogin } from '@capgo/capacitor-social-login';
    await SocialLogin.initialize({
    google: {
    webClientId: 'your-google-web-client-id',
    iOSServerClientId: 'your-google-server-client-id',
    mode: 'online',
    },
    apple: {
    clientId: 'your-apple-service-id',
    useProperTokenExchange: true,
    useBroadcastChannel: true,
    },
    facebook: {
    appId: 'your-facebook-app-id',
    },
    twitter: {
    clientId: 'your-twitter-client-id',
    redirectUrl: 'myapp://oauth/twitter',
    },
    oauth2: {
    github: {
    appId: 'your-github-client-id',
    authorizationBaseUrl: 'https://github.com/login/oauth/authorize',
    accessTokenEndpoint: 'https://github.com/login/oauth/access_token',
    redirectUrl: 'myapp://oauth/github',
    scope: 'read:user user:email',
    pkceEnabled: true,
    },
    },
    });

코어 흐름 예시

코어 흐름 예시 섹션
await SocialLogin.login({
provider: 'google',
options: { scopes: ['profile', 'email'] },
});
await SocialLogin.login({
provider: 'oauth2',
options: {
providerId: 'github',
scope: 'read:user user:email',
},
});
const status = await SocialLogin.isLoggedIn({ provider: 'google' });
await SocialLogin.logout({ provider: 'google' });

인증 코드 및 리프레시

인증 코드 및 리프레시 섹션
// For providers that support this mode
const authCodeResult = await SocialLogin.getAuthorizationCode({ provider: 'google' });
await SocialLogin.refresh({ provider: 'google', options: {} as never });

고급 도우미

고급 도우미 섹션
const jwt = await SocialLogin.decodeIdToken({
idToken: 'eyJhbGciOi...',
});
const { date } = await SocialLogin.getAccessTokenExpirationDate({
accessTokenExpirationDate: Date.now() + 3600 * 1000,
});
const expired = await SocialLogin.isAccessTokenExpired({
accessTokenExpirationDate: Date.now() + 1000,
});
const active = await SocialLogin.isRefreshTokenAvailable({ refreshToken: 'a-token' });

제공자별 참고사항

제공자별 참고사항 섹션

구글 오프라인 모드

구글 오프라인 모드 섹션

google.mode: 'offline' 리턴 serverAuthCode 로그인 모드에서 로그아웃, isLoggedIn, getAuthorizationCode, 및 refresh는 사용할 수 없습니다.

백엔드 토큰 교환에만 사용하세요. 앱에서 호출해야 하는 경우, 백엔드에서 호출하세요. serverAuthCode __CAPGO_KEEP_0__ SocialLogin.refresh() __CAPGO_KEEP_0__ google.mode: 'online' __CAPGO_KEEP_0__

설정 useProperTokenExchange: true strict 토큰 처리를 위해 및 useBroadcastChannel: true Android 단순화된 설정을 위해

OAuth2 웹 리다이렉트 흐름

OAuth2 웹 리다이렉트 흐름 섹션

사용 OAuth2LoginOptions.flow: 'redirect' 페이지에서 벗어날 수 있는 웹 흐름을 위해

Capacitor 구성 제공자

Capacitor 구성 제공자 섹션

__CAPGO_KEEP_0__을 사용하지 않는 제공자들을 비활성화하여 네이티브 바이너리 크기를 줄일 수 있습니다.

import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'com.example.app',
appName: 'My App',
webDir: 'dist',
plugins: {
SocialLogin: {
providers: {
google: true,
facebook: true,
apple: true,
twitter: false,
},
},
},
};

Getting Started에서 계속하기

시작부터 계속하기

이미 시작하기 인증 및 계정 흐름을 계획하고 Using @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 __CAPGO_KEEP_0__ __CAPGO_KEEP_1__