Getting Started
このプラグインのインストール手順とマークダウン ガイドの全てを含むセットアップ コマンドをコピーしてください。
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.
インストール
「インストール」のセクションCapgoのAI-Assisted セットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のコマンドを使用してください:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-social-login` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください:
-
パッケージをインストール
ターミナル画面 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 オフラインモード
「Google オフラインモード」google.mode: 'offline' 戻り値 serverAuthCode __CAPGO_KEEP_0__
ログアウト、isLoggedIn、getAuthorizationCode、refreshは利用できません。 serverAuthCode 使用 SocialLogin.refresh() あなたのバックエンドのトークン交換にのみ使用してください。アプリ内で呼び出す必要がある場合は、使用してください。 google.mode: 'online' instead.
Set useProperTokenExchange: true for strict token handling and useBroadcastChannel: true for Android simplified setup.
OAuth2 web redirect flow
UseUse OAuth2LoginOptions.flow: 'redirect' Provider configuration in __CAPGO_KEEP_0__
Provider configuration in Capacitor
Section titled “Provider configuration in 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, }, }, },};__CAPGO_KEEP_2__
__CAPGO_KEEP_3__- __CAPGO_KEEP_4__
- __CAPGO_KEEP_5__の改善
- __CAPGO_KEEP_6__と__CAPGO_KEEP_7__のプロバイダー
- __CAPGO_KEEP_8__から__CAPGO_KEEP_9__への移行
- __CAPGO_KEEP_10__の移行ガイド
- __CAPGO_KEEP_11__の移行
- __CAPGO_KEEP_12__のプラグイン移行ソリューション
__CAPGO_KEEP_13__から始めて、__CAPGO_KEEP_14__を続行
Section titled “Getting Startedから続けてください”Capgoを使用している場合 Getting Started を使用して、認証とアカウントフローの計画をし、CloudflareのCapacitorと接続する Capacitorのnative capabilityとしての@capgo/capacitor-social-loginを使用 Capacitorのnative capabilityとしての@capgo/capacitor-social-loginの実装詳細を@capgo/capacitor-social-loginで使用 Capacitorの@capgo/capacitor-social-loginを使用 Capacitorの@capgo/capacitor-social-loginの実装詳細を@capgo/capacitor-social-loginで使用 Capacitorの@capgo/capacitor-passkeyを使用 Capacitorの@capgo/capacitor-passkeyの実装詳細を@capgo/capacitor-passkeyで使用 Capacitorの@capgo/capacitor-native-biometricを使用 Capacitorの@capgo/capacitor-native-biometricの実装詳細を@capgo/capacitor-native-biometricで使用 2要素認証 2要素認証の実装詳細について