Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@capacitor-firebase/authentication
Advanced tools
Capacitor plugin for Firebase Authentication.
⚡️ Capacitor plugin for Firebase Authentication.
npm install @capacitor-firebase/authentication firebase
npx cap sync
Add Firebase to your project if you haven't already (Android / iOS / Web).
On Android, please make sure that you are using Java 11.
On iOS, verify that this function is included in your app's AppDelegate.swift
:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
Attention: If you use this plugin on iOS in combination with @capacitor-firebase/messaging
, then add the following to your app's AppDelegate.swift
:
+ import FirebaseAuth
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
+ if Auth.auth().canHandle(url) {
+ return true
+ }
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
The further installation steps depend on the selected authentication method:
Attention: Please note that this plugin uses third-party SDKs to offer native sign-in. These SDKs can initialize on their own and collect various data. Here you can find more information.
These configuration values are available:
Prop | Type | Description | Default | Since |
---|---|---|---|---|
skipNativeAuth | boolean | Configure whether the plugin should skip the native authentication. Only needed if you want to use the Firebase JavaScript SDK. Note that the plugin may behave differently across the platforms. Only available for Android and iOS. | false | 0.1.0 |
providers | string[] | Configure which providers you want to use so that only the providers you need are fully initialized. If you do not configure any providers, they will be all initialized. Please note that this does not prevent the automatic initialization of third-party SDKs. Only available for Android and iOS. | ["apple.com", "facebook.com", "github.com", "google.com", "microsoft.com", "playgames.google.com", "twitter.com", "yahoo.com", "phone"] | 0.1.0 |
In capacitor.config.json
:
{
"plugins": {
"FirebaseAuthentication": {
"skipNativeAuth": false,
"providers": ["apple.com", "google.com"]
}
}
}
In capacitor.config.ts
:
/// <reference types="@capacitor/firebase-authentication" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
FirebaseAuthentication: {
skipNativeAuth: false,
providers: ["apple.com", "google.com"],
},
},
};
export default config;
A working example can be found here: robingenz/capacitor-firebase-authentication-demo
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const applyActionCode = async () => {
await FirebaseAuthentication.applyActionCode({ oobCode: '1234' });
};
const createUserWithEmailAndPassword = async () => {
const result = await FirebaseAuthentication.createUserWithEmailAndPassword({
email: 'mail@exmaple.com',
password: '1234',
});
return result.user;
};
const confirmPasswordReset = async () => {
await FirebaseAuthentication.confirmPasswordReset({
oobCode: '1234',
newPassword: '4321',
});
};
const getCurrentUser = async () => {
const result = await FirebaseAuthentication.getCurrentUser();
return result.user;
};
const getIdToken = async () => {
const currentUser = getCurrentUser();
if (!currentUser) {
return;
}
const result = await FirebaseAuthentication.getIdToken();
return result.token;
};
const sendEmailVerification = async () => {
const currentUser = getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.sendEmailVerification();
};
const sendPasswordResetEmail = async () => {
await FirebaseAuthentication.sendPasswordResetEmail({
email: 'mail@example.com',
});
};
const setLanguageCode = async () => {
await FirebaseAuthentication.setLanguageCode({ languageCode: 'en-US' });
};
const signInWithApple = async () => {
const result = await FirebaseAuthentication.signInWithApple();
return result.user;
};
const signInWithCustomToken = async () => {
const result = await FirebaseAuthentication.signInWithCustomToken({
token: '1234',
});
return result.user;
};
const signInWithEmailAndPassword = async () => {
const result = await FirebaseAuthentication.signInWithEmailAndPassword({
email: 'mail@example.com',
password: '1234',
});
return result.user;
};
const signInWithFacebook = async () => {
const result = await FirebaseAuthentication.signInWithFacebook();
return result.user;
};
const signInWithGithub = async () => {
const result = await FirebaseAuthentication.signInWithGithub();
return result.user;
};
const signInWithGoogle = async () => {
const result = await FirebaseAuthentication.signInWithGoogle();
return result.user;
};
const signInWithMicrosoft = async () => {
const result = await FirebaseAuthentication.signInWithMicrosoft();
return result.user;
};
const signInWithPlayGames = async () => {
const result = await FirebaseAuthentication.signInWithPlayGames();
return result.user;
};
const signInWithPhoneNumber = async () => {
const { verificationId } = await FirebaseAuthentication.signInWithPhoneNumber(
{
phoneNumber: '123456789',
},
);
const verificationCode = window.prompt(
'Please enter the verification code that was sent to your mobile device.',
);
const result = await FirebaseAuthentication.signInWithPhoneNumber({
verificationId,
verificationCode,
});
return result.user;
};
const signInWithTwitter = async () => {
const result = await FirebaseAuthentication.signInWithTwitter();
return result.user;
};
const signInWithYahoo = async () => {
const result = await FirebaseAuthentication.signInWithYahoo();
return result.user;
};
const signOut = async () => {
await FirebaseAuthentication.signOut();
};
const updateEmail = async () => {
const currentUser = getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.updateEmail({
newEmail: 'new.mail@example.com',
});
};
const updatePassword = async () => {
const currentUser = getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.updatePassword({
newPassword: '4321',
});
};
const useAppLanguage = async () => {
await FirebaseAuthentication.useAppLanguage();
};
const useEmulator = async () => {
await FirebaseAuthentication.useEmulator({
host: '10.0.2.2',
port: 9099,
});
};
applyActionCode(...)
createUserWithEmailAndPassword(...)
confirmPasswordReset(...)
getCurrentUser()
getIdToken(...)
sendEmailVerification()
sendPasswordResetEmail(...)
setLanguageCode(...)
signInWithApple(...)
signInWithCustomToken(...)
signInWithEmailAndPassword(...)
signInWithFacebook(...)
signInWithGithub(...)
signInWithGoogle(...)
signInWithMicrosoft(...)
signInWithPhoneNumber(...)
signInWithPlayGames(...)
signInWithTwitter(...)
signInWithYahoo(...)
signOut()
updateEmail(...)
updatePassword(...)
useAppLanguage()
useEmulator(...)
addListener('authStateChange', ...)
removeAllListeners()
applyActionCode(options: ApplyActionCodeOptions) => Promise<void>
Applies a verification code sent to the user by email.
Param | Type |
---|---|
options | ApplyActionCodeOptions |
Since: 0.2.2
createUserWithEmailAndPassword(options: CreateUserWithEmailAndPasswordOptions) => Promise<SignInResult>
Creates a new user account with email and password. If the new account was created, the user is signed in automatically.
Param | Type |
---|---|
options | CreateUserWithEmailAndPasswordOptions |
Returns: Promise<SignInResult>
Since: 0.2.2
confirmPasswordReset(options: ConfirmPasswordResetOptions) => Promise<void>
Completes the password reset process.
Param | Type |
---|---|
options | ConfirmPasswordResetOptions |
Since: 0.2.2
getCurrentUser() => Promise<GetCurrentUserResult>
Fetches the currently signed-in user.
Returns: Promise<GetCurrentUserResult>
Since: 0.1.0
getIdToken(options?: GetIdTokenOptions | undefined) => Promise<GetIdTokenResult>
Fetches the Firebase Auth ID Token for the currently signed-in user.
Param | Type |
---|---|
options | GetIdTokenOptions |
Returns: Promise<GetIdTokenResult>
Since: 0.1.0
sendEmailVerification() => Promise<void>
Sends a verification email to the currently signed in user.
Since: 0.2.2
sendPasswordResetEmail(options: SendPasswordResetEmailOptions) => Promise<void>
Sends a password reset email.
Param | Type |
---|---|
options | SendPasswordResetEmailOptions |
Since: 0.2.2
setLanguageCode(options: SetLanguageCodeOptions) => Promise<void>
Sets the user-facing language code for auth operations.
Param | Type |
---|---|
options | SetLanguageCodeOptions |
Since: 0.1.0
signInWithApple(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Apple sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithCustomToken(options: SignInWithCustomTokenOptions) => Promise<SignInResult>
Starts the Custom Token sign-in flow.
This method cannot be used in combination with skipNativeAuth
on Android and iOS.
In this case you have to use the signInWithCustomToken
interface of the Firebase JS SDK directly.
Param | Type |
---|---|
options | SignInWithCustomTokenOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithEmailAndPassword(options: SignInWithEmailAndPasswordOptions) => Promise<SignInResult>
Starts the sign-in flow using an email and password.
Param | Type |
---|---|
options | SignInWithEmailAndPasswordOptions |
Returns: Promise<SignInResult>
Since: 0.2.2
signInWithFacebook(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Facebook sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithGithub(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the GitHub sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithGoogle(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Google sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithMicrosoft(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Microsoft sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithPhoneNumber(options: SignInWithPhoneNumberOptions) => Promise<SignInWithPhoneNumberResult>
Starts the sign-in flow using a phone number.
Either the phone number or the verification code and verification ID must be provided.
Only available for Android and iOS.
Param | Type |
---|---|
options | SignInWithPhoneNumberOptions |
Returns: Promise<SignInWithPhoneNumberResult>
Since: 0.1.0
signInWithPlayGames(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Play Games sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithTwitter(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Twitter sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signInWithYahoo(options?: SignInOptions | undefined) => Promise<SignInResult>
Starts the Yahoo sign-in flow.
Param | Type |
---|---|
options | SignInOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
signOut() => Promise<void>
Starts the sign-out flow.
Since: 0.1.0
updateEmail(options: UpdateEmailOptions) => Promise<void>
Updates the email address of the currently signed in user.
Param | Type |
---|---|
options | UpdateEmailOptions |
Since: 0.1.0
updatePassword(options: UpdatePasswordOptions) => Promise<void>
Updates the password of the currently signed in user.
Param | Type |
---|---|
options | UpdatePasswordOptions |
Since: 0.1.0
useAppLanguage() => Promise<void>
Sets the user-facing language code to be the default app language.
Since: 0.1.0
useEmulator(options: UseEmulatorOptions) => Promise<void>
Instrument your app to talk to the Authentication emulator.
Param | Type |
---|---|
options | UseEmulatorOptions |
Since: 0.2.0
addListener(eventName: 'authStateChange', listenerFunc: AuthStateChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for the user's sign-in state changes.
Param | Type |
---|---|
eventName | 'authStateChange' |
listenerFunc | AuthStateChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 0.1.0
removeAllListeners() => Promise<void>
Remove all listeners for this plugin.
Since: 0.1.0
Prop | Type | Description | Since |
---|---|---|---|
oobCode | string | A verification code sent to the user. | 0.2.2 |
Prop | Type | Description | Since |
---|---|---|---|
user | User | null | The currently signed-in user, or null if there isn't any. | 0.1.0 |
credential | AuthCredential | null | Credentials returned by an auth provider. | 0.1.0 |
additionalUserInfo | AdditionalUserInfo | null | Additional user information from a federated identity provider. | 0.5.1 |
Prop | Type | Since |
---|---|---|
displayName | string | null | 0.1.0 |
email | string | null | 0.1.0 |
emailVerified | boolean | 0.1.0 |
isAnonymous | boolean | 0.1.0 |
phoneNumber | string | null | 0.1.0 |
photoUrl | string | null | 0.1.0 |
providerId | string | 0.1.0 |
tenantId | string | null | 0.1.0 |
uid | string | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
providerId | string | The authentication provider ID for the credential. | 0.1.0 |
accessToken | string | The OAuth access token associated with the credential if it belongs to an OAuth provider. | 0.1.0 |
idToken | string | The OAuth ID token associated with the credential if it belongs to an OIDC provider. | 0.1.0 |
secret | string | The OAuth access token secret associated with the credential if it belongs to an OAuth 1.0 provider. | 0.1.0 |
nonce | string | The random string used to make sure that the ID token you get was granted specifically in response to your app's authentication request. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
isNewUser | boolean | Whether the user is new (sign-up) or existing (sign-in). | 0.5.1 |
profile | { [key: string]: unknown; } | Map containing IDP-specific user data. | 0.5.1 |
providerId | string | Identifier for the provider used to authenticate this user. | 0.5.1 |
username | string | The username if the provider is GitHub or Twitter. | 0.5.1 |
Prop | Type | Since |
---|---|---|
email | string | 0.2.2 |
password | string | 0.2.2 |
Prop | Type | Description | Since |
---|---|---|---|
oobCode | string | A verification code sent to the user. | 0.2.2 |
newPassword | string | The new password. | 0.2.2 |
Prop | Type | Description | Since |
---|---|---|---|
user | User | null | The currently signed-in user, or null if there isn't any. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
token | string | The Firebase Auth ID token JWT string. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
forceRefresh | boolean | Force refresh regardless of token expiration. | 0.1.0 |
Prop | Type | Since |
---|---|---|
email | string | 0.2.2 |
Prop | Type | Description | Since |
---|---|---|---|
languageCode | string | BCP 47 language code. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
customParameters | SignInCustomParameter[] | Configures custom parameters to be passed to the identity provider during the OAuth sign-in flow. | 0.1.0 |
scopes | string[] | Scopes to request from provider. | 0.3.1 |
Prop | Type | Description | Since |
---|---|---|---|
key | string | The custom parameter key (e.g. login_hint ). | 0.1.0 |
value | string | The custom parameter value (e.g. user@firstadd.onmicrosoft.com ). | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
token | string | The custom token to sign in with. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
email | string | The users email address. | 0.2.2 |
password | string | The users password. | 0.2.2 |
Prop | Type | Description | Since |
---|---|---|---|
verificationId | string | The verification ID, which is needed to identify the verification code. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
phoneNumber | string | The phone number to be verified. | 0.1.0 |
verificationId | string | The verification ID which will be returned when signInWithPhoneNumber is called for the first time. The verificationCode must also be provided. | 0.1.0 |
verificationCode | string | The verification code from the SMS message. The verificationId must also be provided. | 0.1.0 |
Prop | Type | Description | Since |
---|---|---|---|
newEmail | string | The new email address. | 0.2.2 |
Prop | Type | Description | Since |
---|---|---|---|
newPassword | string | The new password. | 0.2.2 |
Prop | Type | Description | Default | Since |
---|---|---|---|---|
host | string | The emulator host (e.g. 10.0.2.2 ). | 0.2.0 | |
port | number | The emulator port (e.g. 9099 ). | 9099 | 0.2.0 |
Prop | Type |
---|---|
remove | () => Promise<void> |
Prop | Type | Description | Since |
---|---|---|---|
user | User | null | The currently signed-in user, or null if there isn't any. | 0.1.0 |
Callback to receive the user's sign-in state change notifications.
(change: AuthStateChange): void
See CHANGELOG.md.
See LICENSE.
This plugin is based on the Capacitor Firebase Authentication plugin. Thanks to everyone who contributed to the project!
FAQs
Capacitor plugin for Firebase Authentication.
The npm package @capacitor-firebase/authentication receives a total of 8,574 weekly downloads. As such, @capacitor-firebase/authentication popularity was classified as popular.
We found that @capacitor-firebase/authentication demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.