はじめから続ける
インストールステップとこのプラグインのフルマークダウンガイドまでのすべてのステップを含むセットアップの質問をコピーする。
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' });プロバイダースペシフィックノート
Section titled “Provider-specific notes”Google offline mode
Section titled “Google offline mode”google.mode: 'offline' returns serverAuthCode from login. In this mode logout, isLoggedIn, getAuthorizationCode, and refresh are not available.
Use serverAuthCode only as input to your backend token exchange. If you need to call SocialLogin.refresh() in the app, use google.mode: 'online' instead.
Set useProperTokenExchange: true 厳格なトークン処理と useBroadcastChannel: true Androidの簡略化されたセットアップ用
OAuth2 Webリダイレクトフロー
「OAuth2 Webリダイレクトフロー」のセクション使用 OAuth2LoginOptions.flow: 'redirect' ページから離れるWebフロー用
Capacitor内のプロバイダーの設定
「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, }, }, },};関連するドキュメント
「関連するドキュメント」のセクション- 統合概要
- より良いAuth統合
- OAuth2およびOIDCプロバイダー
- Ionic Auth Connectから移行
- Social Login Auth Connectの移行ガイド
- 古いプロバイダーを移行
- Ionic Enterpriseプラグインの移行ソリューション
Getting Startedから続けて
Getting Startedから続けてのセクションCapgoを使用している場合 Getting Started アカウントフローと認証を計画するには、ここから始めて @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 Two-factor authentication Edit page