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-firebase-authentication`
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/firebase-authentication/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.
インストール
「インストール」のセクション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-firebase-authentication` plugin in my project.手動設定を好む場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください:
bun add @capgo/capacitor-firebase-authenticationbunx cap syncインポート
「インポート」タイトル付のセクションimport { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';API オーバービュー
「API オーバービュー」タイトル付のセクションapplyActionCode
「applyActionCode」タイトル付のセクションメールで送信された確認codeを適用します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.applyActionCode({} as ApplyActionCodeOptions);confirmPasswordReset
パスワードリセットの確認パスワードリセットプロセスを完了します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmPasswordReset({} as ConfirmPasswordResetOptions);confirmVerificationCode
確認用の認証コードの確認電話番号の確認プロセスを完了します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmVerificationCode({} as ConfirmVerificationCodeOptions);createUserWithEmailAndPassword
ユーザーを作成するユーザーを作成し、メールアドレスとパスワードを使用して新しいユーザーアカウントを作成します。 新しいアカウントが作成された場合、ユーザーは自動的にログインされます。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.createUserWithEmailAndPassword({} as CreateUserWithEmailAndPasswordOptions);deleteUser
ユーザーを削除する__CAPGO_KEEP_0__を削除し、ユーザーをログアウトします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.deleteUser();fetchSignInMethodsForEmail
「fetchSignInMethodsForEmail」セクション指定されたメールアドレスのサインイン方法を取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.fetchSignInMethodsForEmail({} as FetchSignInMethodsForEmailOptions);getCurrentUser
「getCurrentUser」セクション現在サインインしているユーザーを取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getCurrentUser();getPendingAuthResult
「getPendingAuthResult」セクションサインインフローが開始された場合に、OSがアプリをバックグラウンドでクリーンアップした場合に返します。 SignInResult Androidのみで利用可能です。
コピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getPendingAuthResult();getIdToken
「getIdToken」を含むセクション現在サインインしているユーザーのFirebase Auth IDトークンを取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdToken();getIdTokenResult
「getIdTokenResult」を含むセクションFirebaseサービスにユーザーを識別するために使用されるデシリアライズされたJSON Webトークン (JWT) を返します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdTokenResult();getRedirectResult
「getRedirectResult」を含むセクションリダイレクトベースのサインインフローから取得します。 SignInResult サインインが失敗した場合、エラーで失敗します。
リダイレクトオペレーションが呼び出されなかった場合、ユーザーがnullの場合のデフォルト値を返します。
クリップボードにコピー SignInResult リダイレクトオペレーションが呼び出されなかった場合、nullのユーザーを含むデフォルト値を返します。
Only available for Web.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getRedirectResult();getTenantId
getTenantIdのセクションテナントIDを取得
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getTenantId();isSignInWithEmailLink
isSignInWithEmailLinkのセクションメールアドレスでサインインするためのリンクが来る場合にチェックします。 signInWithEmailLink.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.isSignInWithEmailLink({} as IsSignInWithEmailLinkOptions);linkWithApple
linkWithAppleのセクションApple認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithApple();linkWithEmailAndPassword
「linkWithEmailAndPassword」セクションEmail認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailAndPassword({} as LinkWithEmailAndPasswordOptions);linkWithEmailLink
「linkWithEmailLink」セクションEmail認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailLink({} as LinkWithEmailLinkOptions);linkWithFacebook
「linkWithFacebook」セクションFacebookを使用した認証プロバイダとユーザーアカウントをリンクします。
nativeレイヤーでログインしている必要があります。
skipNativeAuth 設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithFacebook();linkWithGameCenter
linkWithGameCenterGame Centerを使用した認証プロバイダとユーザーアカウントをリンクします。
nativeレイヤーでログインしている必要があります。
skipNativeAuth 設定オプションはここでは効果がありません。
iOSのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGameCenter();linkWithGithub
linkWithGithubGitHubを使用した認証プロバイダとユーザーアカウントをリンクします。
native層でログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGithub();linkWithGoogle
タイトル:「linkWithGoogle」Google認証プロバイダとユーザーアカウントをリンクします。
native層でログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGoogle();linkWithMicrosoft
タイトル:「linkWithMicrosoft」Microsoft認証プロバイダとユーザーアカウントをリンクします。
native層でログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithMicrosoft();linkWithOpenIdConnect
__CAPGO_KEEP_1__OpenID Connectを使用したユーザーアカウントのリンク
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithOpenIdConnect({} as LinkWithOpenIdConnectOptions);linkWithPhoneNumber
__CAPGO_KEEP_1__電話番号認証プロバイダとユーザーアカウントをリンク
ユーザーはネイティブ層でログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
Use the phoneVerificationCompleted listener to be notified when the verification is completed.
Use the phoneVerificationFailed listener to be notified when the verification is failed.
Use the phoneCodeSent listener to get the verification id.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPhoneNumber({} as LinkWithPhoneNumberOptions);linkWithPlayGames
セクション:「linkWithPlayGames」Play Games認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
Androidのみ対応
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPlayGames();linkWithTwitter
セクション:「linkWithTwitter」Twitter認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithTwitter();linkWithYahoo
Section titled “linkWithYahoo”Yahooとの連携
ユーザーはnative layerでログインしている必要があります。
skipNativeAuth 設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithYahoo();reload
Section titled “reload”ユーザーアカウントデータを再読み込みします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.reload();revokeAccessToken
Section titled “revokeAccessToken”指定されたアクセストークンを取り消します。現在はApple OAuthアクセストークンのみをサポートしています。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({} as RevokeAccessTokenOptions);sendEmailVerification
Section titled “sendEmailVerification”現在のサインインユーザーに確認メールを送信します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendEmailVerification();sendPasswordResetEmail
セクション「sendPasswordResetEmail」パスワードリセットメールを送信します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({} as SendPasswordResetEmailOptions);sendSignInLinkToEmail
セクション「sendSignInLinkToEmail」指定されたメールアドレスのユーザーにサインインメールリンクを送信します。
メールリンクでサインインを完了するには、 signInWithEmailLink 指定されたメールアドレスとメールリンクを使用してください。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendSignInLinkToEmail({} as SendSignInLinkToEmailOptions);setLanguageCode
セクション「setLanguageCode」認証オペレーションでユーザー向けの言語をcodeに設定します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setLanguageCode({} as SetLanguageCodeOptions);setPersistence
__CAPGO_KEEP_1____CAPGO_KEEP_2__
__CAPGO_KEEP_3__
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setPersistence({} as SetPersistenceOptions);setTenantId
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setTenantId({} as SetTenantIdOptions);signInAnonymously
__CAPGO_KEEP_5____CAPGO_KEEP_1__
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInAnonymously();signInWithApple
__CAPGO_KEEP_7__Appleサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithApple();signInWithCustomToken
signInWithCustomTokenセクションカスタムトークンを使用したサインインフローを開始します。
このメソッドは、AndroidおよびiOSで使用することはできません。
この場合、Firebase JS __CAPGO_KEEP_0__の直接インターフェイスを使用する必要があります。 skipNativeAuth コピー signInWithCustomToken interface of the Firebase JS SDK directly.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithCustomToken({} as SignInWithCustomTokenOptions);signInWithEmailAndPassword
コピーsignInWithEmailLinkセクション
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailAndPassword({} as SignInWithEmailAndPasswordOptions);signInWithEmailLink
コピーSigns in using an email and sign-in email link.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailLink({} as SignInWithEmailLinkOptions);signInWithFacebook
Section titled “signInWithFacebook”Starts the Facebook sign-in flow.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithFacebook();signInWithGameCenter
Section titled “signInWithGameCenter”Starts the Game Center sign-in flow.
Only available for iOS.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGameCenter();signInWithGithub
Section titled “signInWithGithub”Starts the GitHub sign-in flow.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGithub();signInWithGoogle
signInWithGoogleのセクションGoogleでサインインのフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGoogle();signInWithMicrosoft
signInWithMicrosoftのセクションMicrosoftでサインインのフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithMicrosoft();signInWithOpenIdConnect
signInWithOpenIdConnectのセクションOpenID Connectでサインインのフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithOpenIdConnect({} as SignInWithOpenIdConnectOptions);signInWithPhoneNumber
signInWithPhoneNumberのセクション電話番号を使用してサインインのフローを開始します。
使用する phoneVerificationCompleted リスナーを通知するためのものです。検証が完了したときに通知されます。
検証が完了したときに通知するリスナーを使用します。
phoneVerificationFailed リスナーを通知するためのものです。検証が失敗したときに通知されます。
検証が失敗したときに通知するリスナーを使用します。
phoneCodeSent 検証IDを取得するリスナーを取得します。
AndroidとiOSのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({} as SignInWithPhoneNumberOptions);signInWithPlayGames
signInWithPlayGamesというセクションPlay Gamesのサインインフローを開始します。
Androidのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPlayGames();signInWithTwitter
signInWithTwitterというセクションTwitterのサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithTwitter();signInWithYahoo
Yahooサインインフローを開始します。コピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithYahoo();signOut
コピープロバイダをユーザーアカウントから削除します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signOut();unlink
メールアドレスを更新します。コピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.unlink({} as UnlinkOptions);updateEmail
__CAPGO_KEEP_0____CAPGO_KEEP_0__
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({} as UpdateEmailOptions);updatePassword
updatePasswordのセクション現在ログイン中のユーザーのパスワードを更新します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({} as UpdatePasswordOptions);updateProfile
updateProfileのセクションユーザーのプロファイルデータを更新します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({} as UpdateProfileOptions);useAppLanguage
useAppLanguageのセクションユーザー向けの言語codeをデフォルトのアプリ言語に設定します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useAppLanguage();useEmulator
useEmulatorのセクションアプリをAuthenticationエミュレータと通信するように設定します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useEmulator({} as UseEmulatorOptions);verifyBeforeUpdateEmail
「verifyBeforeUpdateEmail」セクション現在ログイン中のユーザーのメールアドレスを更新する前に、新しいメールアドレスを検証します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.verifyBeforeUpdateEmail({} as VerifyBeforeUpdateEmailOptions);checkAppTrackingTransparencyPermission
「checkAppTrackingTransparencyPermission」セクション現在のアプリのトラッキング透明性の状態を確認します。
iOSのみ
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.checkAppTrackingTransparencyPermission();requestAppTrackingTransparencyPermission
「requestAppTrackingTransparencyPermission」セクションシステムのダイアログを開いてアプリのトラッキング透明性の許可を求めます。
注意: ユーザーは、デバイスの設定でトラッキングの要求を無効にしている可能性があります。詳細は Appleのドキュメントを参照してください.
iOSのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.requestAppTrackingTransparencyPermission();型参照
型参照のセクションApplyActionCodeOptions
アプリケーションコード実行オプションの確認export interface ApplyActionCodeOptions { /** * A verification code sent to the user. * * @since 0.2.2 */ oobCode: string;}ConfirmPasswordResetOptions
パスワードリセットの確認オプションの確認export interface ConfirmPasswordResetOptions { /** * A verification code sent to the user. * * @since 0.2.2 */ oobCode: string; /** * The new password. * * @since 0.2.2 */ newPassword: string;}ConfirmVerificationCodeOptions
確認コードの確認オプションの確認export interface ConfirmVerificationCodeOptions { /** * The verification ID received from the `phoneCodeSent` listener. * * The `verificationCode` option must also be provided. * * @since 5.0.0 */ verificationId: string; /** * The verification code either received from the `phoneCodeSent` listener or entered by the user. * * The `verificationId` option must also be provided. * * @since 5.0.0 */ verificationCode: string;}SignInResult
サインイン結果のセクションexport interface SignInResult { /** * The currently signed-in user, or null if there isn't any. * * @since 0.1.0 */ user: User | null; /** * Credentials returned by an auth provider. * * @since 0.1.0 */ credential: AuthCredential | null; /** * Additional user information from a federated identity provider. * * @since 0.5.1 */ additionalUserInfo: AdditionalUserInfo | null;}CreateUserWithEmailAndPasswordOptions
ユーザーを作成するオプションのセクションexport interface CreateUserWithEmailAndPasswordOptions { /** * @since 0.2.2 */ email: string; /** * @since 0.2.2 */ password: string;}FetchSignInMethodsForEmailOptions
メールアドレスに対するサインイン方法を取得するオプションのセクションexport interface FetchSignInMethodsForEmailOptions { /** * The user's email address. * * @since 6.0.0 */ email: string;}FetchSignInMethodsForEmailResult
メールアドレスに対するサインイン方法を取得する結果のセクションexport interface FetchSignInMethodsForEmailResult { /** * The sign-in methods for the specified email address. * * This list is empty when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) * is enabled, irrespective of the number of authentication methods available for the given email. * * @since 6.0.0 */ signInMethods: string[];}GetCurrentUserResult
現在のユーザーの結果のセクションexport interface GetCurrentUserResult { /** * The currently signed-in user, or null if there isn't any. * * @since 0.1.0 */ user: User | null;}GetIdTokenOptions
IDトークンを取得するオプションのセクションexport interface GetIdTokenOptions { /** * Force refresh regardless of token expiration. * * @since 0.1.0 */ forceRefresh: boolean;}GetIdTokenResult
IDトークンを取得する結果のセクションexport interface GetIdTokenResult { /** * The Firebase Auth ID token JWT string. * * @since 0.1.0 */ token: string;}GetIdTokenResultOptions
「GetIdTokenResultOptions」セクションexport interface GetIdTokenResultOptions { /** * Force refresh regardless of token expiration. * * @since 7.4.0 */ forceRefresh: boolean;}GetIdTokenResultResult
「GetIdTokenResultResult」セクションexport interface GetIdTokenResultResult { /** * The authentication time in milliseconds since the epoch. * * This is the time the user authenticated (signed in) and not the time the token was refreshed. * * @since 7.4.0 */ authTime: number; /** * The ID token expiration time in milliseconds since the epoch. * * @since 7.4.0 */ expirationTime: number; /** * The ID token issuance time in milliseconds since the epoch. * * @since 7.4.0 */ issuedAtTime: number; /** * The sign-in provider through which the ID token was obtained. * * @since 7.4.0 */ signInProvider: string | null; /** * The type of second factor associated with this session, provided the user was multi-factor * authenticated (eg. phone, etc). * * @since 7.4.0 */ signInSecondFactor: string | null; /** * The entire payload claims of the ID token including the standard reserved claims as well as * the custom claims. * * @since 7.4.0 */ claims: Record<string, unknown>;}真実の源
「真実の源」セクションこのページはプラグインから生成されています。 src/definitions.tsパブリック API がアップストリームで変更された場合に再度同期を実行してください。
Getting Started から続けてください。
「Getting Started から続けてください」セクションCapacitor を使用している場合 「Getting Started から続けてください」 を認証とアカウントフローの計画に使用し、 @capgo/capacitor-social-login @capgo/capacitor-social-loginの実装詳細については @capgo/capacitor-passkey @capgo/capacitor-passkeyの実装詳細については @capgo/capacitor-native-biometric @capgo/capacitor-native-biometricの実装詳細については 2要素認証 2要素認証の実装詳細については、 SSO (Enterprise) SSO (Enterprise)の実装詳細については。