__CAPGO_KEEP_0__ - __CAPGO_KEEP_1__のライブアップデート

Firebase Authenticationの__CAPGO_KEEP_0__リポジトリ

GitHub

CapgoのAIアシスタントを使用してプラグインをインストールできます。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.

Manual Setupを使用する場合は、以下のコマンドを実行してください。プラットフォーム固有の指示に従ってください。

ターミナル画面
bun add @capgo/capacitor-firebase-authentication
bunx cap sync
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';

API Overview

「API Overview」

applyActionCode

「applyActionCode」

code を適用します。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);

ユーザーを削除し、ログアウトします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.deleteUser();

メールアドレスのサインイン方法を取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.fetchSignInMethodsForEmail({} as FetchSignInMethodsForEmailOptions);

現在ログインしているユーザーを取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getCurrentUser();

取得する SignInResult アプリがウェブサインインフローを実行した場合、OSがアプリをバックグラウンドでクリーンアップした場合に返します。

Androidのみ利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getPendingAuthResult();

現在サインインしているユーザーのFirebase Auth IDトークンを取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdToken();

JSON Web Token (JWT)をデシリアライズして、ユーザーをFirebaseサービスに識別するために使用します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdTokenResult();

取得する SignInResult リダイレクトベースのサインインフローから。

サインインが失敗した場合、エラーで失敗します。 リダイレクト操作が呼び出されなかった場合、ユーザーがnullの場合を返します。 SignInResult ユーザーがnullの場合を返します。

Webのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getRedirectResult();

テナントIDを取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getTenantId();

Incomingリンクがメールアドレスでサインインに適したものであるかどうかを確認します。 signInWithEmailLink.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.isSignInWithEmailLink({} as IsSignInWithEmailLinkOptions);

Apple認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithApple();

メール認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailAndPassword({} as LinkWithEmailAndPasswordOptions);

メール認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth 設定オプションはここでは効果を発揮しません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailLink({} as LinkWithEmailLinkOptions);

Facebook認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth 設定オプションはここでは効果を発揮しません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithFacebook();

Game Center認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth 設定オプションはここでは効果を発揮しません。

iOSのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGameCenter();

GitHub認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGithub();

Google認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGoogle();

Microsoft認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithMicrosoft();

OpenID Connectプロバイダとユーザーアカウントをリンクします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithOpenIdConnect({} as LinkWithOpenIdConnectOptions);

Phone Number認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

使用する phoneVerificationCompleted 通知待機 phoneVerificationFailed 通知待機 phoneCodeSent 認証ID取得

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPhoneNumber({} as LinkWithPhoneNumberOptions);

Play Games認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

Androidのみ対応

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPlayGames();

Twitter認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithTwitter();

ユーザーアカウントをYahoo認証プロバイダーとリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithYahoo();

ユーザーアカウントデータを再読み込みします。ログインしている場合。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.reload();

指定されたアクセストークンを取り消します。現在はApple OAuthアクセストークンのみをサポートしています。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({} as RevokeAccessTokenOptions);

現在のユーザーに確認メールを送信します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendEmailVerification();

パスワードリセットメールを送信します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({} as SendPasswordResetEmailOptions);

指定されたメールアドレスにサインイン用のリンクを送信します。

サインイン用のメールリンクを使用してサインインを完了するには、 signInWithEmailLink 指定されたメールアドレスとメールリンクを使用して呼び出してください。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendSignInLinkToEmail({} as SendSignInLinkToEmailOptions);

codeのためのユーザーフェイス言語を設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setLanguageCode({} as SetLanguageCodeOptions);

現在の認証セッションの保存方法を設定します。

Webのみで利用可能

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setPersistence({} as SetPersistenceOptions);

テナントIDを設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setTenantId({} as SetTenantIdOptions);

匿名ユーザーとしてサインインします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInAnonymously();

Apple サインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithApple();

カスタム トークン サインインフローを開始します。

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

signInWithCustomToken

メールアドレスとパスワードを使用したサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailAndPassword({} as SignInWithEmailAndPasswordOptions);

メールアドレスとサインインメールリンクを使用してサインインします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailLink({} as SignInWithEmailLinkOptions);

Facebookサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithFacebook();

ゲームセンターのサインインフローを開始します。

iOSのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGameCenter();

signInWithGithub

GitHubでサインイン

GitHubのサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGithub();

signInWithGoogle

Googleでサインイン

Googleのサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGoogle();

signInWithMicrosoft

Microsoftでサインイン

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);

電話番号を使用してサインインフローを開始します。

「成功」リスナーを使用して、検証が完了したときに通知を受けます。 phoneVerificationCompleted 「失敗」リスナーを使用して、検証が失敗したときに通知を受けます。 phoneVerificationFailed 「検証ID」リスナーを使用して、検証IDを取得します。 phoneCodeSent AndroidおよびiOSのみで利用可能です。

コピー

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({} as SignInWithPhoneNumberOptions);

Androidのみで利用可能です。

コピー

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPlayGames();

Twitterでサインインのフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithTwitter();

Yahooでサインインのフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithYahoo();

サインアウトのフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signOut();

ユーザーアカウントからプロバイダをリンク解除します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.unlink({} as UnlinkOptions);

現在ログイン中のユーザーのメールアドレスを更新します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({} as UpdateEmailOptions);

現在ログイン中のユーザーのパスワードを更新します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({} as UpdatePasswordOptions);

ユーザーのプロフィールデータを更新します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({} as UpdateProfileOptions);

Sets the user-facing language code to be the default app language.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useAppLanguage();

アプリをAuthenticationエミュレータと通信するように設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useEmulator({} as UseEmulatorOptions);

現在ログイン中のユーザーのメールアドレスを更新する前に、新しいメールアドレスを検証します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.verifyBeforeUpdateEmail({} as VerifyBeforeUpdateEmailOptions);

アプリのトラッキング透明性の現在の状態を確認します。

iOSのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.checkAppTrackingTransparencyPermission();

システムダイアログを開いてアプリのトラッキング透明性の許可を求めます。

注意: ユーザーは、デバイスの設定でトラッキングリクエストを無効にしている可能性があります。詳しくは Appleのドキュメント.

iOSのみで利用可能

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.requestAppTrackingTransparencyPermission();
export interface ApplyActionCodeOptions {
/**
* A verification code sent to the user.
*
* @since 0.2.2
*/
oobCode: string;
}
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;
}
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;
}
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;
}
export interface CreateUserWithEmailAndPasswordOptions {
/**
* @since 0.2.2
*/
email: string;
/**
* @since 0.2.2
*/
password: string;
}
export interface FetchSignInMethodsForEmailOptions {
/**
* The user's email address.
*
* @since 6.0.0
*/
email: string;
}
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[];
}
export interface GetCurrentUserResult {
/**
* The currently signed-in user, or null if there isn't any.
*
* @since 0.1.0
*/
user: User | null;
}
export interface GetIdTokenOptions {
/**
* Force refresh regardless of token expiration.
*
* @since 0.1.0
*/
forceRefresh: boolean;
}
export interface GetIdTokenResult {
/**
* The Firebase Auth ID token JWT string.
*
* @since 0.1.0
*/
token: string;
}
export interface GetIdTokenResultOptions {
/**
* Force refresh regardless of token expiration.
*
* @since 7.4.0
*/
forceRefresh: boolean;
}
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」から続けて進む

あなたが使用している Getting Started 認証とアカウントフローの計画に使用している場合 @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, 2要素認証の実装詳細については Two-factor authentication SSO (Enterprise) SSO (Enterprise)の実装詳細については