Passer à la navigation

Getting Started

GitHub

Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil d'IA en utilisant la commande suivante :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Ensuite, utilisez la prompt suivante :

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-authentication` plugin in my project.

Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :

Fenêtre de terminal
bun add @capgo/capacitor-firebase-authentication
bunx cap sync
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';

Applique une vérification code envoyée à l'utilisateur par email.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.applyActionCode({ oobCode: 'oob-code' });

Completes the password reset process.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmPasswordReset({
oobCode: 'oob-code',
newPassword: 'new-password',
});

Termine le processus de vérification du numéro de téléphone.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.confirmVerificationCode({
verificationId: 'phoneCodeSent',
verificationCode: 'phoneCodeSent',
});
// The result holds sensitive values: use it without logging it.

Crée un nouveau compte utilisateur avec email et mot de passe. Si le nouveau compte a été créé, l'utilisateur est connecté automatiquement.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.createUserWithEmailAndPassword({
email: 'user@example.com',
password: 'password',
});
// The result holds sensitive values: use it without logging it.

Supprime et déconnecte l'utilisateur.

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

Récupère les méthodes de connexion pour une adresse email.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.fetchSignInMethodsForEmail({ email: 'user@example.com' });
console.log(result);

Récupère l'utilisateur actuellement connecté.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getCurrentUser();
// The result holds sensitive values: use it without logging it.

Renvoie le SignInResult Si votre application lance une session de connexion web et que le système nettoie l'application pendant son exécution en arrière-plan.

Seulement disponible pour Android.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getPendingAuthResult();
// The result holds sensitive values: use it without logging it.

Récupère le jeton d'authentification Firebase ID pour l'utilisateur actuellement connecté.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getIdToken();
// The result holds sensitive values: use it without logging it.

Renvoie un jeton Web JSON désérialisé (JWT) utilisé pour identifier l'utilisateur à un service Firebase.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getIdTokenResult();
// The result holds sensitive values: use it without logging it.

Renvoie le SignInResult à partir du flux de connexion basé sur la redirection.

Si l'authentification n'a pas réussi, elle échoue avec une erreur. Si aucune redirection n'a été appelée, elle retourne un SignInResult avec un utilisateur null.

Seulement disponible pour Web.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getRedirectResult();
// The result holds sensitive values: use it without logging it.

Obtenez l'identifiant de locataire.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getTenantId();
console.log(result);

Vérifie si un lien entrant est un lien de connexion par e-mail approprié pour signInWithEmailLink.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.isSignInWithEmailLink({ emailLink: 'https://example.com' });
// The result holds sensitive values: use it without logging it.

Associe le compte utilisateur au fournisseur d'authentification Apple.

L’utilisateur doit être connecté sur la couche native. skipNativeAuth L’option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithApple();
// The result holds sensitive values: use it without logging it.

Associe le compte utilisateur au fournisseur d'authentification par e-mail.

L’utilisateur doit être connecté sur la couche native. skipNativeAuth L’option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithEmailAndPassword({
email: 'user@example.com',
password: 'password',
});
// The result holds sensitive values: use it without logging it.

Liaison de l'account utilisateur avec le fournisseur d'authentification Email.

L'utilisateur doit être connecté sur la couche native. La skipNativeAuth configuration option n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithEmailLink({
email: 'user@example.com',
emailLink: 'https://example.com',
});
// The result holds sensitive values: use it without logging it.

Liaison de l'account utilisateur avec le fournisseur d'authentification Facebook.

L'utilisateur doit être connecté sur la couche native. La skipNativeAuth configuration option n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithFacebook();
// The result holds sensitive values: use it without logging it.

S'associe à l'authentification du fournisseur Game Center.

L'utilisateur doit être connecté sur la couche native. skipNativeAuth Cette option de configuration n'a pas d'effet ici.

Disponible uniquement pour iOS.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithGameCenter();
// The result holds sensitive values: use it without logging it.

S'associe à l'authentification du fournisseur GitHub.

L'utilisateur doit être connecté sur la couche native. skipNativeAuth Cette option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithGithub();
// The result holds sensitive values: use it without logging it.

S'associe à l'authentification du fournisseur Google.

L'utilisateur doit être connecté sur la couche native. skipNativeAuth Cette option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithGoogle();
// The result holds sensitive values: use it without logging it.

Liaison de la compte utilisateur avec le fournisseur d'authentification Microsoft.

L'utilisateur doit être connecté sur la couche native. skipNativeAuth Cette option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithMicrosoft();
// The result holds sensitive values: use it without logging it.

Liaison de la compte utilisateur avec un fournisseur OpenID Connect.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithOpenIdConnect({ providerId: 'provider-id-123' });
// The result holds sensitive values: use it without logging it.

Associe l'identifiant de compte à l'authentification par numéro de téléphone.

L’utilisateur doit être connecté sur la couche native. skipNativeAuth Cette option de configuration n'a pas d'effet ici.

Utilisez le phoneVerificationCompleted Écoutez pour être averti lorsque la vérification est terminée. phoneVerificationFailed Écoutez pour être averti lorsque la vérification a échoué. phoneCodeSent Écoutez pour obtenir l'ID de vérification.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPhoneNumber({ phoneNumber: "+16505550101" });

Authentifiez le compte utilisateur avec le fournisseur d'authentification Play Games.

L’utilisateur doit être connecté sur la couche native. skipNativeAuth Cette option de configuration n'a pas d'effet ici.

Disponible uniquement pour Android.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithPlayGames();
// The result holds sensitive values: use it without logging it.

Liaise l'account utilisateur avec le fournisseur d'authentification Twitter.

L'utilisateur doit être connecté sur la couche native. La skipNativeAuth option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithTwitter();
// The result holds sensitive values: use it without logging it.

Liaise l'account utilisateur avec le fournisseur d'authentification Yahoo.

L'utilisateur doit être connecté sur la couche native. La skipNativeAuth option de configuration n'a pas d'effet ici.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithYahoo();
// The result holds sensitive values: use it without logging it.

Rafraîchit les données du compte utilisateur, si connecté.

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

Annule l'accès au jeton spécifié. Actuellement, uniquement pris en charge pour les jetons OAuth Apple.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({ token: 'token-123' });

Envoie un e-mail de vérification au utilisateur actuellement connecté.

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

Envoie un e-mail de réinitialisation de mot de passe.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({ email: 'user@example.com' });

Envoie un lien de connexion par courriel au utilisateur avec l'adresse e-mail spécifiée.

Pour terminer la connexion avec le lien de courriel, appelez signInWithEmailLink avec l'adresse e-mail et le lien de courriel fournis dans le courriel envoyé à l'utilisateur.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendSignInLinkToEmail({
email: 'user@example.com',
actionCodeSettings: { url: 'https://example.com' },
});

Définit le code de langue code affiché pour les opérations d'authentification.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setLanguageCode({ languageCode: "en-US" });

Définit le type de persistance pour la session d'authentification enregistrée actuellement.

Seulement disponible pour Web.

import { FirebaseAuthentication, Persistence } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setPersistence({ persistence: Persistence.IndexedDbLocal });

Définit l'identifiant de locataire.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setTenantId({ tenantId: 'tenant-id-123' });

S'authentifie en tant qu'utilisateur anonyme.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInAnonymously();
// The result holds sensitive values: use it without logging it.

Démarre le flux de connexion Apple.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithApple();
// The result holds sensitive values: use it without logging it.

Démarre le flux de connexion avec jeton personnalisé.

Cette méthode ne peut pas être utilisée en combinaison avec skipNativeAuth on Android and iOS. In this case you have to use the signInWithCustomToken interface of the Firebase JS SDK directly.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithCustomToken({ token: 'token-123' });
// The result holds sensitive values: use it without logging it.

Titre de la section « signInWithEmailLink »

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithEmailAndPassword({
email: 'user@example.com',
password: 'password',
});
// The result holds sensitive values: use it without logging it.

Titre de la section « signInWithFacebook »

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithEmailLink({
email: 'user@example.com',
emailLink: 'https://example.com',
});
// The result holds sensitive values: use it without logging it.

interface de Firebase JS

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithFacebook();
// The result holds sensitive values: use it without logging it.

Démarrera le flux de connexion Game Center.

Disponible uniquement sur iOS.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithGameCenter();
// The result holds sensitive values: use it without logging it.

Démarrera le flux de connexion GitHub.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithGithub();
// The result holds sensitive values: use it without logging it.

Démarrera le flux de connexion Google.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithGoogle();
// The result holds sensitive values: use it without logging it.

Démarrera le flux de connexion Microsoft.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithMicrosoft();
// The result holds sensitive values: use it without logging it.

Démarre le flux de connexion OpenID Connect.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithOpenIdConnect({ providerId: 'provider-id-123' });
// The result holds sensitive values: use it without logging it.

Démarre le flux de connexion à l'aide d'un numéro de téléphone.

Utilisez le phoneVerificationCompleted pour être averti lorsque la vérification est terminée. Utilisez le phoneVerificationFailed pour être averti lorsque la vérification a échoué. Utilisez le phoneCodeSent pour obtenir l'ID de vérification.

Seulement disponible pour Android et iOS.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({ phoneNumber: "+16505550101" });

Démarrer le flux de connexion à Play Games.

Disponible uniquement pour Android.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithPlayGames();
// The result holds sensitive values: use it without logging it.

Démarrer le flux de connexion à Twitter.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithTwitter();
// The result holds sensitive values: use it without logging it.

Démarrer le flux de connexion à Yahoo.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithYahoo();
// The result holds sensitive values: use it without logging it.

Démarrer le flux de déconnexion.

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

Délie un fournisseur d'un compte utilisateur.

import { FirebaseAuthentication, ProviderId } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.unlink({ providerId: ProviderId.APPLE });
// The result holds sensitive values: use it without logging it.

Met à jour l'adresse e-mail de l'utilisateur actuellement connecté.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({ newEmail: 'user@example.com' });

Met à jour le mot de passe de l'utilisateur actuellement connecté.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({ newPassword: 'new-password' });

Met à jour les données de profil de l'utilisateur.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({
displayName: 'display',
photoUrl: 'https://example.com',
});

Définit la langue utilisée par l’application code comme langue par défaut de l’application.

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

Instrumentez votre application pour communiquer avec l’émulateur d’authentification.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useEmulator({ host: "127.0.0.1" });

Vérifiez l’adresse e-mail nouvelle avant de mettre à jour l’adresse e-mail de l’utilisateur actuellement connecté.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.verifyBeforeUpdateEmail({ newEmail: 'user@example.com' });

checkAppTrackingTransparencyPermission

Vérifiez la permission de suivi de l'application

Vérifiez le statut actuel de la permission de suivi de l’application.

Disponible uniquement sur iOS.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.checkAppTrackingTransparencyPermission();
console.log(result);

requestAppTrackingTransparencyPermission

Demande de permission de suivi de l'application

Ouvre le dialogue système pour autoriser la transparence de suivi de l'application.

Attention : L'utilisateur peut avoir désactivé la demande de suivi dans les paramètres du dispositif, voir La documentation d'Apple.

Disponible uniquement sur iOS.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.requestAppTrackingTransparencyPermission();
console.log(result);
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>;
}

Cette page est générée à partir du plugin’s src/definitions.tsRe-run la synchronisation lorsque le public API change en amont.

Si vous utilisez Getting Started pour planifier l'authentification et les flux de compte, connectez-l’avec @capgo/capacitor-connexion-social pour les détails d'implémentation dans @capgo/capacitor-connexion-social, @capgo/capacitor-mot-de-passe pour les détails d'implémentation dans @capgo/capacitor-mot-de-passe, @capgo/capacitor-native-biometrique pour les détails d'implémentation dans @capgo/capacitor-native-biometrique L'authentification à deux facteurs pour les détails d'implémentation dans L'authentification à deux facteurs, et SSO (Entreprise) pour les détails d'implémentation dans SSO (Entreprise).