はじめに
このプラグインのインストールステップとフルマークダウンガイドを含む設定用の質問をコピーする。
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
「applyActionCode」セクションユーザーにメールで送信された確認用codeを適用します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.applyActionCode({} as ApplyActionCodeOptions);confirmPasswordReset
「confirmPasswordReset」セクションパスワードのリセットプロセスを完了します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmPasswordReset({} as ConfirmPasswordResetOptions);confirmVerificationCode
「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
ユーザー削除ユーザーを削除し、サインアウトします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.deleteUser();fetchSignInMethodsForEmail
メールアドレスのサインイン方法を取得メールアドレスのサインイン方法を取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.fetchSignInMethodsForEmail({} as FetchSignInMethodsForEmailOptions);getCurrentUser
現在サインインしているユーザーを取得現在サインインしているユーザーを取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getCurrentUser();getPendingAuthResult
Web サインインフローを起動した場合の待機中の認証結果を取得アプリがバックグラウンドでクリーンアップされるときに、 SignInResult if your app launched a web sign-in flow and the OS cleans up the app while in the background.
Androidのみで利用可能です。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getPendingAuthResult();getIdToken
「getIdToken」をクリック現在サインインしているユーザーのFirebase Auth ID Tokenを取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdToken();getIdTokenResult
「getIdTokenResult」をクリックJSON Web Token (JWT)をデシリアライズして、Firebaseサービスにユーザーを識別するために使用します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdTokenResult();getRedirectResult
「getRedirectResult」をクリックリダイレクトベースのサインインフローから SignInResult サインインが失敗した場合、エラーで失敗します。
リダイレクトオペレーションが呼び出されていない場合、空のオブジェクトを返します。
__CAPGO_KEEP_0__ SignInResult __CAPGO_KEEP_0__は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
Facebook連携Facebook認証プロバイダとユーザーアカウントをリンクします。
nativeレイヤーでログインしている必要があります。
skipNativeAuth この設定オプションはここでは効果がありません。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithFacebook();linkWithGameCenter
iOS用のGame Center認証プロバイダとユーザーアカウントをリンクします。nativeレイヤーでログインしている必要があります。
この設定オプションはここでは効果がありません。 skipNativeAuth iOSのみ
コピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGameCenter();linkWithGithub
nativeレイヤーでログインしている必要があります。
この設定オプションはここでは効果がありません。GitHubを使用した認証プロバイダとユーザーアカウントをリンクします。
nativeレイヤーでログインしている必要があります。
設定オプションはここでは効果がありません。 skipNativeAuth クリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGithub();linkWithGoogle
nativeレイヤーでログインしている必要があります。
設定オプションはここでは効果がありません。クリップボードにコピー
Section titled “linkWithGoogle” skipNativeAuth Microsoft認証プロバイダとユーザーアカウントをリンクします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGoogle();linkWithMicrosoft
クリップボードにコピーSection titled “linkWithMicrosoft”
__CAPGO_KEEP_0__を使用した認証プロバイダとユーザーアカウントをリンクします。 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」セクションPhone Number 認証プロバイダーとユーザーアカウントをリンクします。
ユーザーはネイティブ層でログインしている必要があります。
skipNativeAuth 設定オプションはここでは効果を発揮しません。
を使用して、検証が完了したときに通知を受け取ることができます。 phoneVerificationCompleted を使用して、検証が失敗したときに通知を受け取ることができます。 phoneVerificationFailed を使用して、検証が失敗したときに通知を受け取ることができます。 phoneCodeSent 認証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
「Yahooとのリンク」を含むセクションユーザーはYahooの認証プロバイダとリンクします。
ユーザーはネイティブレイヤーでログインしている必要があります。
この設定オプションはここでは効果がありません。 skipNativeAuth クリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithYahoo();クリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.reload();revokeAccessToken
指定されたアクセストークンを剥奪します。現在はApple OAuthアクセストークンのみをサポートしています。クリップボードにコピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({} as RevokeAccessTokenOptions);sendEmailVerification
Section titled “sendEmailVerification”Sends a verification email to the currently signed in user.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendEmailVerification();sendPasswordResetEmail
Section titled “sendPasswordResetEmail”Sends a password reset email.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({} as SendPasswordResetEmailOptions);sendSignInLinkToEmail
Section titled “sendSignInLinkToEmail”Sends a sign-in email link to the user with the specified email.
To complete sign in with the email link, call signInWithEmailLink with the email address and the email link supplied in the email sent to the user.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendSignInLinkToEmail({} as SendSignInLinkToEmailOptions);setLanguageCode
Section titled “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現在保存されている認証セッションのテナントIDを設定します。
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
Appleサインインフローを開始します。Appleサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithApple();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
AndroidおよびiOSでは、このメソッドを組み合わせることはできません。
この場合、Firebase JS __CAPGO_KEEP_0__の直接インターフェイスを使用する必要があります。メールアドレスとパスワードを使用したサインインフローを開始します。
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
GitHubのサインインフローを開始します。Starts the GitHub sign-in flow.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGithub();signInWithGoogle
Googleサインインフローを開始します。サインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGoogle();signInWithMicrosoft
Microsoftサインインフローを開始します。コピー
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithMicrosoft();signInWithOpenIdConnect
コピー電話番号を使用したサインインフローを開始します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithOpenIdConnect({} as SignInWithOpenIdConnectOptions);signInWithPhoneNumber
サインインフローを開始します。コピー
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.
Only available for Android and iOS.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({} as SignInWithPhoneNumberOptions);signInWithPlayGames
Section titled “signInWithPlayGames”Starts the Play Games sign-in flow.
Only available for Android.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPlayGames();signInWithTwitter
Section titled “signInWithTwitter”Starts the Twitter sign-in flow.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithTwitter();signInWithYahoo
「Yahooでサインイン」セクション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
「メールアドレスの更新」セクション現在サインインしているユーザーのメールアドレスを更新します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({} as UpdateEmailOptions);updatePassword
「パスワードの更新」を含むセクション現在ログイン中のユーザーのパスワードを更新します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({} as UpdatePasswordOptions);updateProfile
「プロフィールの更新」を含むセクションユーザーのプロフィールデータを更新します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({} as UpdateProfileOptions);useAppLanguage
「アプリの言語」を含むセクションSets the user-facing language code to be the default app language.
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useAppLanguage();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
「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
セクション「ユーザーを作成するための電子メールとパスワードのオプション」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.tsAPIがアップストリームで変更された場合に再度同期を実行してください。
Getting Startedから続けて
「Getting Startedから続けて」のセクションCapgoを使用している場合 Getting Started to plan authentication and account flows, connect it with @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, Two-factor authentication for the implementation detail in Two-factor authentication, and SSO (Enterprise) for the implementation detail in SSO (Enterprise).