시작하기
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 지시를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-social-login`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/social-login/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
-
패키지를 설치하세요
터미널 창 bun add @capgo/capacitor-social-login -
자연어 프로젝트와 동기화
터미널 창 bunx cap sync -
앱 시작 시 초기화
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 modeconst 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' returns serverAuthCode 로그인에서 __CAPGO_KEEP_0__을 사용합니다. 이 모드에서는 로그아웃, isLoggedIn, getAuthorizationCode, 및 refresh가 사용할 수 없습니다.
사용 serverAuthCode __CAPGO_KEEP_0__을 백엔드 토큰 교환에만 사용하세요. 앱에서 호출해야 하는 경우 __CAPGO_KEEP_1__을 사용하세요. SocialLogin.refresh() 애플 google.mode: 'online' 애플 섹션
__CAPGO_KEEP_0__
__CAPGO_KEEP_1__strict 모드 설정 useProperTokenExchange: true Android용 단순한 설정을 위해 useBroadcastChannel: true OAuth2 웹 리다이렉트 흐름
OAuth2 웹 리다이렉트 흐름
페이지에서 벗어나서 웹 흐름을 사용하기 위해__CAPGO_KEEP_0__의 제공자 구성 OAuth2LoginOptions.flow: 'redirect' __CAPGO_KEEP_0__의 제공자 구성
Provider configuration in Capacitor
Section titled “Provider configuration in Capacitor”관련 문서
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, }, }, },};