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.
インストール
「インストール」のセクションbun add @capgo/capacitor-firebase-authenticationbunx cap syncインポート
セクション:インポートimport { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';API オーバービュー
セクション:API オーバービューapplyActionCode
セクション:applyActionCodeApplies a verification code sent to the user by email.
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
「createUserWithEmailAndPassword」セクションメールアドレスとパスワードを使用して新しいユーザーアカウントを作成します。 新しいアカウントが作成された場合、ユーザーは自動的にログインされます。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.createUserWithEmailAndPassword({} as CreateUserWithEmailAndPasswordOptions);deleteUser
「deleteUser」セクションユーザーを削除してログアウトします。
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」セクション__CAPGO_KEEP_1__ SignInResult アプリがWebサインインフローを開始し、OSがアプリをバックグラウンドでクリーンアップした場合にのみ利用可能です。
__CAPGO_KEEP_2__
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getPendingAuthResult();getIdToken
__CAPGO_KEEP_3__現在サインインしているユーザーのFirebase Auth IDトークンを取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdToken();getIdTokenResult
「getIdTokenResult」セクション__CAPGO_KEEP_5__
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdTokenResult();getRedirectResult
「getRedirectResult」セクションから取得します。 SignInResult リダイレクトベースのサインインフローから
サインインが失敗した場合は、エラーで失敗します。
リダイレクト操作が呼び出されなかった場合は、ユーザーがnullの場合に返されます。 SignInResult Webのみで利用可能です。
クリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getRedirectResult();getTenantId
テナントIDを取得します。クリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getTenantId();isSignInWithEmailLink
クリップボードにコピーメールアドレスでサインインするためのリンクが来る場合にチェックします。 signInWithEmailLink.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.isSignInWithEmailLink({} as IsSignInWithEmailLinkOptions);linkWithApple
「linkWithApple」セクションApple認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
このオプションはここでは効果がありません。 skipNativeAuth __CAPGO_KEEP_0__をクリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithApple();linkWithEmailAndPassword
Email認証プロバイダとユーザーアカウントをリンクします。ユーザーはネイティブレイヤーでログインしている必要があります。 このオプションはここでは効果がありません。
__CAPGO_KEEP_0__をクリップボードにコピー skipNativeAuth linkWithApple
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailAndPassword({} as LinkWithEmailAndPasswordOptions);linkWithEmailLink
Section titled “linkWithEmailLink”Links the user account with Email authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailLink({} as LinkWithEmailLinkOptions);linkWithFacebook
Section titled “linkWithFacebook”Links the user account with Facebook authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithFacebook();linkWithGameCenter
Section titled “linkWithGameCenter”Links the user account with Game Center authentication provider.
ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。
iOSのみ対応。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGameCenter();linkWithGithub
「linkWithGithub」セクションGitHub認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGithub();linkWithGoogle
「linkWithGoogle」セクションGoogle認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth 設定オプションはここでは効果を発揮しません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGoogle();linkWithMicrosoft
「linkWithMicrosoft」セクションユーザー アカウントを Microsoft 認証プロバイダーとリンクします。
ユーザーはネイティブ層でログインしている必要があります。
skipNativeAuth 設定オプションはここでは効果を発揮しません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithMicrosoft();linkWithOpenIdConnect
「linkWithOpenIdConnect」セクションユーザー アカウントを OpenID Connect プロバイダーとリンクします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithOpenIdConnect({} as LinkWithOpenIdConnectOptions);linkWithPhoneNumber
「linkWithPhoneNumber」セクションユーザー アカウントを電話番号認証プロバイダーとリンクします。
native層でログインしている必要があります。
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
Section titled “linkWithPlayGames”Links the user account with Play Games authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
Play Games認証プロバイダーとユーザーアカウントをリンクします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPlayGames();linkWithTwitter
「Twitterとリンクする」セクションTwitter認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithTwitter();linkWithYahoo
「Yahooとリンクする」セクションYahoo認証プロバイダとユーザーアカウントをリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithYahoo();reload
「再読み込み」セクション__CAPGO_KEEP_0__を更新します。サインインしている場合にのみ。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.reload();revokeAccessToken
「__CAPGO_KEEP_0__」セクション指定されたApple OAuthアクセストークンを取り消します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({} as RevokeAccessTokenOptions);sendEmailVerification
「__CAPGO_KEEP_0__」セクション現在サインインしているユーザーに確認メールを送信します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendEmailVerification();sendPasswordResetEmail
「__CAPGO_KEEP_0__」セクションパスワードリセットメールを送信します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({} as SendPasswordResetEmailOptions);sendSignInLinkToEmail
「__CAPGO_KEEP_0__」セクション指定されたメールアドレスに送信されたユーザーにメールリンクを送信します。
メールリンクでサインインを完了するには、 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
「setPersistence」セクション現在保存されている認証セッションの保存方法を設定します。
Webのみで利用可能
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setPersistence({} as SetPersistenceOptions);setTenantId
「setTenantId」セクション__CAPGO_KEEP_0__を設定します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setTenantId({} as SetTenantIdOptions);signInAnonymously
「signInAnonymously」セクション匿名ユーザーとしてサインインします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInAnonymously();signInWithApple
「signInWithApple」セクションAppleサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithApple();signInWithCustomToken
「signInWithCustomToken」セクションカスタムトークンによるサインインフローを開始します。
このメソッドは skipNativeAuth AndroidとiOSでは使用できません。
この場合、__CAPGO_KEEP_2__を使用する必要があります。 signInWithCustomToken Firebase JS SDK のインターフェイスを直接使用します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithCustomToken({} as SignInWithCustomTokenOptions);signInWithEmailAndPassword
「signInWithEmailAndPassword」セクションメールアドレスとパスワードを使用してサインインのフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailAndPassword({} as SignInWithEmailAndPasswordOptions);signInWithEmailLink
「signInWithEmailLink」セクションメールアドレスとサインイン用メールリンクを使用してサインインします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailLink({} as SignInWithEmailLinkOptions);signInWithFacebook
「signInWithFacebook」セクションFacebookのサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithFacebook();signInWithGameCenter
「signInWithGameCenter」セクションGame Center のサインインフローを開始します。
iOS でのみ利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGameCenter();signInWithGithub
signInWithGithub のセクションGitHub のサインインフローを開始します。
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
OpenID ConnectでサインインするOpenID Connectでサインインのフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithOpenIdConnect({} as SignInWithOpenIdConnectOptions);signInWithPhoneNumber
電話番号でサインインする電話番号でサインインのフローを開始します。
使用して phoneVerificationCompleted 検証が完了したときに通知を受け取るリスナーを使用します。 phoneVerificationFailed 検証が失敗したときに通知を受け取るリスナーを使用します。 phoneCodeSent 検証IDを取得するリスナーを使用します。
AndroidとiOSのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({} as SignInWithPhoneNumberOptions);signInWithPlayGames
Play GamesでサインインするPlay Gamesのサインインフローを開始します。
Androidのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPlayGames();signInWithTwitter
TwitterサインインフローPlay Gamesのサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithTwitter();signInWithYahoo
YahooサインインフローPlay Gamesのサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithYahoo();signOut
サインアウトフローPlay Gamesのサインアウトフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signOut();unlink
Section titled “unlink”Unlinks a provider from a user account.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.unlink({} as UnlinkOptions);updateEmail
Section titled “updateEmail”Updates the email address of the currently signed in user.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({} as UpdateEmailOptions);updatePassword
Section titled “updatePassword”Updates the password of the currently signed in user.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({} as UpdatePasswordOptions);updateProfile
Section titled “updateProfile”Updates a user’s profile data.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({} as UpdateProfileOptions);useAppLanguage
useAppLanguagecodeをデフォルトのアプリ言語として設定します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useAppLanguage();useEmulator
useEmulatorアプリをエミュレータと通信するように設定します。
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
「ApplyActionCodeOptions」セクションexport interface ApplyActionCodeOptions { /** * A verification code sent to the user. * * @since 0.2.2 */ oobCode: string;}ConfirmPasswordResetOptions
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
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
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
CreateUserWithEmailAndPasswordOptionsの確認export interface CreateUserWithEmailAndPasswordOptions { /** * @since 0.2.2 */ email: string; /** * @since 0.2.2 */ password: string;}FetchSignInMethodsForEmailOptions
FetchSignInMethodsForEmailOptionsの確認export interface FetchSignInMethodsForEmailOptions { /** * The user's email address. * * @since 6.0.0 */ email: string;}FetchSignInMethodsForEmailResult
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
Section titled “GetCurrentUserResult”export interface GetCurrentUserResult { /** * The currently signed-in user, or null if there isn't any. * * @since 0.1.0 */ user: User | null;}GetIdTokenOptions
Section titled “GetIdTokenOptions”export interface GetIdTokenOptions { /** * Force refresh regardless of token expiration. * * @since 0.1.0 */ forceRefresh: boolean;}GetIdTokenResult
Section titled “GetIdTokenResult”export interface GetIdTokenResult { /** * The Firebase Auth ID token JWT string. * * @since 0.1.0 */ token: string;}GetIdTokenResultOptions
Section titled “GetIdTokenResultOptions”export interface GetIdTokenResultOptions { /** * Force refresh regardless of token expiration. * * @since 7.4.0 */ forceRefresh: boolean;}GetIdTokenResultResult
Section titled “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>;}Source Of Truth
Section titled “Source Of Truth”このページはプラグインから生成されます。 src/definitions.ts. upstream の public API が変更されたときに再度 Sync を実行してください。
Getting Started から続けてください。
Getting Started から続けてください。あなたが「Getting Started」を使用している場合 Getting Started 認証とアカウントフローの計画に使用している場合、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login に接続してください。 @capgo/capacitor-social-login の実装詳細については @capgo/capacitor-social-login を参照してください。 @capgo/capacitor-passkey の実装詳細については @capgo/capacitor-passkey を参照してください。 @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric 実装詳細のために @capgo/capacitor-native-biometric に 2要素認証 実装詳細のために 2要素認証、 SSO (企業) 実装詳細のために SSO (企業)。