Skip to content

Getting Started

GitHub

Capgoの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';

ユーザーにメールで送信された確認用codeを適用します。

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

パスワードリセットプロセスを完了します。

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

電話番号の確認プロセスを完了します。

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

メールアドレスとパスワードを使用して新しいユーザーアカウントを作成します。 新しいアカウントが作成された場合、ユーザーは自動的にログインされます。

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

アプリがWebサインインフローを開始し、OSがバックグラウンドでアプリをクリーンアップした場合に返します。 SignInResult Copy to clipboard

Only available for Android.

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

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

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

ユーザーをFirebaseサービスに識別するために使用されるJSON Web Token (JWT)を返します。

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

redirectベースのサインインフローから SignInResult サインインが失敗した場合、エラーで失敗します。 redirect操作が呼び出されていなかった場合、空のオブジェクトを返します。

__CAPGO_KEEP_0__ SignInResult __CAPGO_KEEP_0__

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

メールアドレスでサインインするためのリンクが来ましたか? 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();

ユーザー アカウントを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);

linkWithFacebook

Facebook連携

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

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

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

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

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

iOSのみ

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

GitHubの認証プロバイダーとユーザーアカウントを関連付けます。

nativeレイヤーでログインしている必要があります。 設定オプションはここでは効果がありません。 skipNativeAuth __CAPGO_KEEP_0__

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

nativeレイヤーでログインしている必要があります。 設定オプションはここでは効果がありません。

コピー skipNativeAuth Microsoft認証プロバイダーとユーザーアカウントを関連付けます。

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

linkWithMicrosoft

コピー

__CAPGO_KEEP_0__の認証プロバイダーとユーザーアカウントを関連付けます。

nativeレイヤーでログインしている必要があります。 設定オプションはここでは効果がありません。 skipNativeAuth __CAPGO_KEEP_0__はここでは効果がありません。

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 __CAPGO_KEEP_0__はここでは効果がありません。

__CAPGO_KEEP_2__を使用して、検証が完了したときに通知を受け取ることができます。 __CAPGO_KEEP_2__を使用して、検証が失敗したときに通知を受け取ることができます。 __CAPGO_KEEP_2__を使用して、検証が失敗したときに通知を受け取ることができます。 phoneVerificationCompleted __CAPGO_KEEP_2__を使用して、検証が完了したときに通知を受け取ることができます。 phoneVerificationFailed __CAPGO_KEEP_2__を使用して、検証が失敗したときに通知を受け取ることができます。 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();

linkWithYahoo

__CAPGO_KEEP_1__

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

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

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

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

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

revokeAccessToken

__CAPGO_KEEP_1__

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

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

Sends a verification email to the currently signed in user.

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

Sends a password reset email.

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

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

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

セクションのタイトル:「signInWithApple」

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

このメソッドは、AndroidとiOSで組み合わせることができません。 この場合、Firebase JS __CAPGO_KEEP_0__の直接インターフェイスを使用する必要があります。

セクションのタイトル:「signInWithEmailAndPassword」 skipNativeAuth メールアドレスとパスワードを使用してサインインフローを開始します。 signInWithCustomToken interface of the Firebase JS SDK directly.

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

signInWithEmailAndPassword

コピーをクリップボードに

コピーをクリップボードに

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

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

iOSのみで利用可能です。

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

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

signInWithOpenIdConnect

OpenID Connectでサインインを開始します。

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

signInWithPhoneNumber

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

Starts the Play Games sign-in flow.

Only available for Android.

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

Starts the Twitter sign-in flow.

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

signInWithYahoo

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_3__

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

__CAPGO_KEEP_4__

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

updateEmail

__CAPGO_KEEP_1__

__CAPGO_KEEP_5__

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

ユーザー向けの言語codeをデフォルトのアプリ言語に設定します。

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

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

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

verifyBeforeUpdateEmail

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

checkAppTrackingTransparencyPermission

__CAPGO_KEEP_1__

__CAPGO_KEEP_3__

__CAPGO_KEEP_4__

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

requestAppTrackingTransparencyPermission

__CAPGO_KEEP_5__

__CAPGO_KEEP_6__

__CAPGO_KEEP_7__ __CAPGO_KEEP_8__ 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.tsAPIがアップストリームで変更された場合に再度同期を実行してください。

Capgoを使用している場合 はじめに を計画し、認証とアカウントフローの接続に @capgo/capacitor-social-login @capgo/capacitor-social-loginの実装詳細について @capgo/capacitor-passkey @capgo/capacitor-passkeyの実装詳細について @capgo/capacitor-native-biometric @capgo/capacitor-native-biometricの実装詳細について 二要素認証 二要素認証の実装詳細について、 SSO (Enterprise) SSO (Enterprise)の実装詳細について