リアルタイムで更新を管理して、__CAPGO_KEEP_4__アプリを無償で

Firebase Authenticationの__CAPGO_KEEP_0__リポジトリ

GitHub

インストール

Install

AI-Assisted Setupを使用してプラグインをインストールすることができます。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」

__CAPGO_KEEP_0__ を完了します。

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

confirmVerificationCode

「confirmVerificationCode」

__CAPGO_KEEP_0__ を完了します。

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トークン(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();

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

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

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

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

ユーザーはネイティブレイヤーでログインしている必要があります。 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);

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

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

Capgoを使用して 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();

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

pagePath

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

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

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

「verificationCompleted」リスナーを使用して、検証が完了されたときに通知を受けます。 phoneVerificationCompleted 「verificationFailed」リスナーを使用して、検証が失敗したときに通知を受けます。 phoneVerificationFailed 「verificationId」リスナーを使用して、検証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 @capgo/capacitor-social-loginの実装詳細 @capgo/capacitor-passkey @capgo/capacitor-passkeyの実装詳細 @capgo/capacitor-native-biometric @capgo/capacitor-native-biometricの実装詳細 2要素認証 2要素認証の実装詳細 SSO (Enterprise) SSO (Enterprise)の実装詳細については