Authentication reference¶
At a glance¶
Auth¶
| Member | Notes |
|---|---|
Auth.auth() |
The shared instance |
current_user |
A User, or None |
add_state_did_change_listener(listener) / add_id_token_did_change_listener(listener) |
listener(user); returns an AuthStateListener (.remove()) |
sign_in_with_email_password(email, password, cb) / create_user_with_email_password(...) |
cb(AuthDataResult, error) |
sign_in_anonymously(cb), sign_in_with_custom_token(token, cb) |
|
sign_in_with_credential(credential, cb), sign_in_with_provider(OAuthProvider, cb) |
|
send_sign_in_link(email, settings, cb), is_sign_in_with_email_link(link), sign_in_with_email_link(email, link, cb) |
Passwordless |
send_password_reset(email, cb, settings), verify_password_reset_code(code, cb), confirm_password_reset(code, password, cb) |
|
check_action_code(code, cb), apply_action_code(code, cb) |
cb(ActionCodeInfo, error) / cb(error) |
sign_out(), update_current_user(user, cb), revoke_token(code, cb) |
|
get_stored_user(access_group) |
(user, error): the user in a shared keychain |
use_emulator(host, port), is_using_emulator, language_code, use_app_language(), tenant_id, app_verification_disabled_for_testing, use_user_access_group(group) |
Settings |
can_handle_url(url), can_handle_notification(user_info), set_apns_token(token, type) |
App delegate hooks (phone, OAuth) |
User¶
- Profile:
uid,email,display_name,phone_number,photo_url,provider_id,is_anonymous,is_email_verified,provider_data(list ofUserInfo),metadata(UserMetadata:creation_date,last_sign_in_date),tenant_id,refresh_token,is_signed_in - Tokens:
get_id_token(cb, force_refresh=False),get_id_token_result(cb, force_refresh=False)→IDTokenResult(token,claims,expiration_date,issued_at_date,auth_date,sign_in_provider,sign_in_second_factor) - Account:
reload,delete,update_password,update_email,update_profile(cb, *, display_name, photo_url),update_phone_number,send_email_verification,send_email_verification_before_updating_email - Providers:
link_with_credential,link_with_provider,unlink,reauthenticate_with_credential,reauthenticate_with_provider
Credentials and providers¶
| Provider | Make a credential |
|---|---|
EmailAuthProvider |
credential(email, password), credential_with_link(email, link) |
GoogleAuthProvider |
credential(id_token, access_token) (or auth.google) |
OAuthProvider |
OAuthProvider(id, scopes, custom_parameters) for web flows; credential(id, id_token, access_token, raw_nonce); apple_credential(id_token, raw_nonce, given_name, family_name) (or auth.apple) |
PhoneAuthProvider |
verify_phone_number(number, cb), then credential(verification_id, code) |
FacebookAuthProvider |
credential(access_token) |
GitHubAuthProvider |
credential(token) |
TwitterAuthProvider |
credential(token, secret) |
GameCenterAuthProvider |
get_credential(cb) |
Each has a PROVIDER_ID. AuthDataResult has user, additional_user_info
(provider_id, is_new_user, username, profile) and credential.
Multi-factor¶
User.multi_factor→MultiFactor:enrolled_factors,get_session(cb),enroll(assertion, display_name, cb),unenroll(factor_or_uid, cb)MultiFactorInfo(uid,factor_id,display_name,enrollment_date),PhoneMultiFactorInfo(+phone_number)PhoneMultiFactorGenerator.assertion(credential);PhoneAuthProvider.verify_phone_number(..., multi_factor_session=),verify_phone_number_for_sign_in(hint, session, cb)TOTPMultiFactorGenerator.generate_secret(session, cb),assertion_for_enrollment(secret, code),assertion_for_sign_in(enrollment_id, code);TOTPSecret.shared_secret_key(),generate_qr_code_url(account, issuer),open_in_otp_app(url)MultiFactorResolver(fromAuthError.resolver):hints,session,resolve_sign_in(assertion, cb)
Facebook (pyios_firebase.auth.facebook)¶
initialize_facebook(), start_facebook_sign_in(cb, permissions, limited), get_facebook_credential(cb, permissions, limited), sign_out_of_facebook(), on_facebook_handle_url(url), on_facebook_handle_url_kivy(...)
Errors¶
AuthError (keys above, plus resolver for SECOND_FACTOR_REQUIRED) and AuthErrorCode: every FIRAuthErrorCode of the SDK,
by name (EMAIL_ALREADY_IN_USE, WRONG_PASSWORD, REQUIRES_RECENT_LOGIN,
ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL, ...).
pyios_firebase.auth¶
Firebase Authentication.
from pyios_firebase.auth import Auth
auth = Auth.auth()
auth.create_user_with_email_password("ada@example.com", "s3cret!", on_signed_in)
listener = auth.add_state_did_change_listener(lambda user: print("user:", user))
Auth: sign-in (email/password, email link, anonymous, custom token, credentials, OAuth web flows), sign-out, listeners, password reset and action codes, the emulatorUser: profile, ID tokens and claims, account changes, email verification, linking and re-authentication- credentials:
EmailAuthProvider,GoogleAuthProvider,OAuthProvider(Apple, Microsoft, Yahoo, GitHub, OIDC, SAML),PhoneAuthProvider,FacebookAuthProvider,GitHubAuthProvider,TwitterAuthProvider,GameCenterAuthProvider pyios_firebase.auth.google/pyios_firebase.auth.apple: the Google and Apple sign-in sheets- multi-factor (
pyios_firebase.auth.multi_factor): SMS and TOTP second factors AuthError/AuthErrorCode: what failed
Needs the FirebaseAuth framework. Google sign-in also needs
GoogleSignIn; Apple sign-in needs the com.apple.developer.applesignin
entitlement.
Modules:
| Name | Description |
|---|---|
apple |
Sign in with Apple, then Firebase Auth. |
auth |
|
credentials |
Sign-in credentials and the providers that make them. |
errors |
Firebase Authentication errors. |
facebook |
Facebook Login, then Firebase Auth. |
google |
Google Sign-In, then Firebase Auth. |
multi_factor |
Multi-factor authentication: SMS and TOTP (authenticator app) second factors. |
results |
What Firebase Authentication calls give back, as plain Python values. |
user |
|
Classes:
| Name | Description |
|---|---|
Auth |
Firebase Authentication. Get it with |
AuthStateListener |
Given back by |
AuthCredential |
A sign-in credential for one provider. |
EmailAuthProvider |
Credentials for email and password, or email link, sign-in. |
FacebookAuthProvider |
Credentials from Facebook Login access tokens. |
GameCenterAuthProvider |
Credentials for the Game Center player signed in on the device. |
GitHubAuthProvider |
Credentials from GitHub OAuth access tokens (for the web flow, use |
GoogleAuthProvider |
Credentials from Google Sign-In tokens. For the whole flow, see |
OAuthCredential |
A credential from an OAuth provider (Apple, Microsoft, Yahoo, ...). |
OAuthProvider |
A generic OAuth provider: Apple, Microsoft, Yahoo, GitHub, or any OIDC / |
PhoneAuthProvider |
Phone number sign-in: send a code by SMS, then make a credential from it. |
TwitterAuthProvider |
Credentials from Twitter (X) OAuth 1.0 tokens. |
AuthError |
An error from Firebase Authentication (or from a sign-in sheet). |
AuthErrorCode |
The |
MultiFactor |
A user's second factors. Get it with |
MultiFactorAssertion |
Proof of a second factor, for |
MultiFactorInfo |
One enrolled second factor. |
MultiFactorResolver |
Finishes a sign-in that needs a second factor. Get it from |
MultiFactorSession |
Proves the first factor was just completed (or that the user is signed |
PhoneMultiFactorGenerator |
Make SMS second-factor assertions. |
PhoneMultiFactorInfo |
An enrolled SMS second factor. |
TOTPMultiFactorGenerator |
Make TOTP (authenticator app) secrets and assertions. |
TOTPSecret |
A new TOTP secret, to show to the user while they set up their |
ActionCodeInfo |
What |
ActionCodeOperation |
What an email action code (link) is for. The values of |
ActionCodeSettings |
Where email links (password reset, verification, sign-in) lead. |
ActionCodeURL |
The parts of an email action link (password reset, verification, |
AdditionalUserInfo |
Provider details from one sign-in. |
AuthDataResult |
The result of a sign-in, link or re-authentication. |
IDTokenResult |
A Firebase ID token and what it says. |
UserInfo |
A user's profile at one provider (an entry of |
UserMetadata |
When the user was created and last signed in. |
User |
A Firebase user: the signed-in one by default. |
Functions:
| Name | Description |
|---|---|
current_user |
The signed-in |
sign_out |
Sign the current user out of Firebase. Same as |
Attributes:
| Name | Type | Description |
|---|---|---|
APNS_TOKEN_TYPE_PRODUCTION |
Final
|
|
APNS_TOKEN_TYPE_SANDBOX |
Final
|
|
APNS_TOKEN_TYPE_UNKNOWN |
Final
|
|
AUTH_ERROR_DOMAIN |
Final
|
The |
PHONE_FACTOR_ID |
Final
|
The |
TOTP_FACTOR_ID |
Final
|
The |
UNSET |
Final
|
Leave this profile field as it is ( |
APNS_TOKEN_TYPE_PRODUCTION
module-attribute
¶
set_apns_token type: a production APNs token.
APNS_TOKEN_TYPE_SANDBOX
module-attribute
¶
set_apns_token type: a development (sandbox) APNs token.
APNS_TOKEN_TYPE_UNKNOWN
module-attribute
¶
set_apns_token type: let Firebase find out (sandbox or production).
AUTH_ERROR_DOMAIN
module-attribute
¶
The error.domain of Firebase Authentication errors.
PHONE_FACTOR_ID
module-attribute
¶
The factor_id of SMS second factors.
TOTP_FACTOR_ID
module-attribute
¶
The factor_id of TOTP (authenticator app) second factors.
UNSET
module-attribute
¶
Leave this profile field as it is (update_profile).
Auth
¶
Auth(native: ObjCObject | None = None)
Firebase Authentication. Get it with Auth.auth().
::
auth = Auth.auth()
auth.sign_in_with_email_password("ada@example.com", "s3cret!", on_signed_in)
Every callback gets (result, error) (or just (error)), where
error is an AuthError or None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject | None
|
the native |
None
|
Methods:
| Name | Description |
|---|---|
auth |
The shared |
update_current_user |
Make |
sign_out |
Sign the current user out of Firebase (Google, Apple and other |
sign_in_with_email_password |
Sign in with an email address and password. |
create_user_with_email_password |
Create an account with an email address and password, and sign in. |
sign_in_anonymously |
Sign in as a new anonymous user (or the current anonymous one). |
sign_in_with_custom_token |
Sign in with a custom token made by your backend (Admin SDK |
sign_in_with_credential |
Sign in with a credential from any provider. |
sign_in_with_provider |
Sign in through an OAuth provider's web flow (Microsoft, Yahoo, |
send_sign_in_link |
Email a passwordless sign-in link. |
is_sign_in_with_email_link |
Whether |
sign_in_with_email_link |
Sign in with an email link from |
send_password_reset |
Email a password reset link. |
verify_password_reset_code |
Check a password reset code (the |
confirm_password_reset |
Set a new password with a password reset code. |
check_action_code |
Find out what an email action code is for, without using it. |
apply_action_code |
Use an email action code: verify an email address, or recover / change one. |
fetch_sign_in_methods |
The sign-in methods used with |
revoke_token |
Revoke a Sign in with Apple token, before deleting an Apple user |
add_state_did_change_listener |
Listen to sign-in and sign-out. |
add_id_token_did_change_listener |
Listen to sign-in, sign-out and ID token refreshes (about once an |
use_emulator |
Send this app's Auth calls to the local Auth emulator. |
use_app_language |
Set |
use_user_access_group |
Share the signed-in user with other apps (and extensions) through a |
get_stored_user |
The user saved in a keychain access group, without switching to it |
can_handle_url |
Give a URL the app was opened with to Firebase Auth (reCAPTCHA and |
can_handle_notification |
Give a remote notification to Firebase Auth (silent push for phone |
set_apns_token |
Give Firebase Auth the app's APNs device token (phone sign-in). |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
current_user |
User | None
|
The signed-in user, or |
is_using_emulator |
bool
|
True after |
language_code |
str | None
|
The language of emails, SMS and web flows Firebase sends, for |
tenant_id |
str | None
|
The tenant users sign in to (multi-tenancy with Identity Platform), |
app_verification_disabled_for_testing |
bool
|
Skip app verification for phone sign-in with test numbers (set in |
current_user
property
¶
current_user: User | None
The signed-in user, or None.
Right after app start this can be None for a moment while Firebase
restores the saved user; use add_state_did_change_listener to know
for sure.
language_code
property
writable
¶
The language of emails, SMS and web flows Firebase sends, for
example "fr"; None for the project default.
tenant_id
property
writable
¶
The tenant users sign in to (multi-tenancy with Identity Platform),
or None.
app_verification_disabled_for_testing
property
writable
¶
Skip app verification for phone sign-in with test numbers (set in the Firebase console). For tests only.
update_current_user
¶
update_current_user(
user: User, callback: ErrorCallback | None = None
) -> None
Make user the signed-in user (for example one from another
Auth instance or a shared keychain).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
User
|
the user to sign in as. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
sign_out
¶
sign_out() -> AuthError | None
Sign the current user out of Firebase (Google, Apple and other providers keep their own sessions).
Returns:
| Type | Description |
|---|---|
AuthError | None
|
|
sign_in_with_email_password
¶
sign_in_with_email_password(
email: str,
password: str,
callback: DataResultCallback | None = None,
) -> None
Sign in with an email address and password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the email address. |
required |
password
|
str
|
the password. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
create_user_with_email_password
¶
create_user_with_email_password(
email: str,
password: str,
callback: DataResultCallback | None = None,
) -> None
Create an account with an email address and password, and sign in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the email address. |
required |
password
|
str
|
the password (at least 6 characters, or your project's password policy). |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
sign_in_anonymously
¶
Sign in as a new anonymous user (or the current anonymous one).
Link a credential later (User.link_with_credential) to keep the
account when the user signs up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
DataResultCallback | None
|
gets |
None
|
sign_in_with_custom_token
¶
Sign in with a custom token made by your backend (Admin SDK
create_custom_token).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
the custom token. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
sign_in_with_credential
¶
sign_in_with_credential(
credential: AuthCredential,
callback: DataResultCallback | None = None,
) -> None
Sign in with a credential from any provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
AuthCredential
|
the credential, from one of the provider classes. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
sign_in_with_provider
¶
sign_in_with_provider(
provider: OAuthProvider,
callback: DataResultCallback | None = None,
) -> None
Sign in through an OAuth provider's web flow (Microsoft, Yahoo, GitHub, OIDC, SAML), in an in-app browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
OAuthProvider
|
the provider, for example |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
send_sign_in_link
¶
send_sign_in_link(
email: str,
action_code_settings: ActionCodeSettings,
callback: ErrorCallback | None = None,
) -> None
Email a passwordless sign-in link.
Save email on the device: you need it again in
sign_in_with_email_link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
where to send the link. |
required |
action_code_settings
|
ActionCodeSettings
|
where the link leads; |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
is_sign_in_with_email_link
¶
Whether link (a URL the app was opened with) is a sign-in link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
str
|
the full URL. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if it can be passed to |
sign_in_with_email_link
¶
sign_in_with_email_link(
email: str,
link: str,
callback: DataResultCallback | None = None,
) -> None
Sign in with an email link from send_sign_in_link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the address the link was sent to. |
required |
link
|
str
|
the full link the user opened. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
send_password_reset
¶
send_password_reset(
email: str,
callback: ErrorCallback | None = None,
action_code_settings: ActionCodeSettings | None = None,
) -> None
Email a password reset link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the account's email address. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
action_code_settings
|
ActionCodeSettings | None
|
where the link leads, or |
None
|
verify_password_reset_code
¶
verify_password_reset_code(
code: str,
callback: Callable[
[str | None, AuthError | None], None
],
) -> None
Check a password reset code (the oobCode of the link).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
the code. |
required |
callback
|
Callable[[str | None, AuthError | None], None]
|
gets |
required |
confirm_password_reset
¶
confirm_password_reset(
code: str,
new_password: str,
callback: ErrorCallback | None = None,
) -> None
Set a new password with a password reset code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
the |
required |
new_password
|
str
|
the new password. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
check_action_code
¶
check_action_code(
code: str,
callback: Callable[
[ActionCodeInfo | None, AuthError | None], None
],
) -> None
Find out what an email action code is for, without using it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
the |
required |
callback
|
Callable[[ActionCodeInfo | None, AuthError | None], None]
|
gets |
required |
apply_action_code
¶
Use an email action code: verify an email address, or recover / change one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
the |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
fetch_sign_in_methods
¶
fetch_sign_in_methods(
email: str,
callback: Callable[
[list[str] | None, AuthError | None], None
],
) -> None
The sign-in methods used with email.
Deprecated by Firebase: with email enumeration protection on (the default), the list is always empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the email address. |
required |
callback
|
Callable[[list[str] | None, AuthError | None], None]
|
gets |
required |
revoke_token
¶
Revoke a Sign in with Apple token, before deleting an Apple user (App Store rule).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
authorization_code
|
str
|
the |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
add_state_did_change_listener
¶
add_state_did_change_listener(
listener: UserListener,
) -> AuthStateListener
Listen to sign-in and sign-out.
listener runs now with the current user (or None), then each
time a user signs in or out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listener
|
UserListener
|
gets the |
required |
Returns:
| Type | Description |
|---|---|
AuthStateListener
|
An |
add_id_token_did_change_listener
¶
add_id_token_did_change_listener(
listener: UserListener,
) -> AuthStateListener
Listen to sign-in, sign-out and ID token refreshes (about once an hour), for example to keep your backend's copy of the token fresh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listener
|
UserListener
|
gets the |
required |
Returns:
| Type | Description |
|---|---|
AuthStateListener
|
An |
use_emulator
¶
Send this app's Auth calls to the local Auth emulator.
Call it right after core.configure(), before any other Auth call.
Use it only in development and test builds. It also turns app
verification off, so phone sign-in works without APNs or reCAPTCHA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
the emulator's host. |
'127.0.0.1'
|
port
|
int
|
the emulator's port ( |
9099
|
use_user_access_group
¶
use_user_access_group(
access_group: str | None,
) -> AuthError | None
Share the signed-in user with other apps (and extensions) through a keychain access group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_group
|
str | None
|
the keychain group (with your team ID prefix), or
|
required |
Returns:
| Type | Description |
|---|---|
AuthError | None
|
|
get_stored_user
¶
The user saved in a keychain access group, without switching to it (for example the user signed in to your other app).
Sign in as them with update_current_user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_group
|
str | None
|
the keychain access group (with your team ID
prefix), or |
required |
Returns:
| Type | Description |
|---|---|
User | None
|
|
AuthError | None
|
|
tuple[User | None, AuthError | None]
|
capability). |
can_handle_url
¶
Give a URL the app was opened with to Firebase Auth (reCAPTCHA and OAuth redirects).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
the URL. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if Firebase Auth handled it. |
can_handle_notification
¶
Give a remote notification to Firebase Auth (silent push for phone sign-in).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_info
|
dict[str, Any]
|
the notification's |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if it was for Firebase Auth. |
set_apns_token
¶
set_apns_token(
token: bytes, token_type: int = APNS_TOKEN_TYPE_UNKNOWN
) -> None
Give Firebase Auth the app's APNs device token (phone sign-in).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
bytes
|
the device token from
|
required |
token_type
|
int
|
|
APNS_TOKEN_TYPE_UNKNOWN
|
AuthStateListener
¶
AuthStateListener(
handle: ObjCObject,
remove: Callable[[ObjCObject], None],
release: Callable[[], None],
)
Given back by add_state_did_change_listener and
add_id_token_did_change_listener. Call remove() to stop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
ObjCObject
|
the native listener handle. |
required |
remove
|
Callable[[ObjCObject], None]
|
removes the handle from Firebase. |
required |
release
|
Callable[[], None]
|
releases the listener's callback block. |
required |
Methods:
| Name | Description |
|---|---|
remove |
Stop the updates. Safe to call more than once. |
AuthCredential
¶
AuthCredential(native: ObjCObject)
A sign-in credential for one provider.
Make credentials with the provider classes (EmailAuthProvider,
GoogleAuthProvider, ...); you do not create them yourself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
provider |
str
|
The provider ID, for example |
native
property
¶
native: ObjCObject
The FIRAuthCredential, for SDK calls this wrapper does not cover.
EmailAuthProvider
¶
Credentials for email and password, or email link, sign-in.
Methods:
| Name | Description |
|---|---|
credential |
A credential for an email address and password. |
credential_with_link |
A credential for an email address and a sign-in link sent to it. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of email sign-in (both password and link). |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of email sign-in (both password and link).
credential
staticmethod
¶
credential(email: str, password: str) -> AuthCredential
A credential for an email address and password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the email address. |
required |
password
|
str
|
the password. |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
credential_with_link
staticmethod
¶
credential_with_link(
email: str, link: str
) -> AuthCredential
A credential for an email address and a sign-in link sent to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the email address the link was sent to. |
required |
link
|
str
|
the full sign-in link the user opened. |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
FacebookAuthProvider
¶
Credentials from Facebook Login access tokens.
Methods:
| Name | Description |
|---|---|
credential |
A credential from a Facebook access token. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of Facebook sign-in. |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of Facebook sign-in.
credential
staticmethod
¶
credential(access_token: str) -> AuthCredential
A credential from a Facebook access token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
str
|
the access token Facebook Login gave. |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
GameCenterAuthProvider
¶
Credentials for the Game Center player signed in on the device.
Methods:
| Name | Description |
|---|---|
get_credential |
A credential for the local Game Center player. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of Game Center sign-in. |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of Game Center sign-in.
get_credential
staticmethod
¶
A credential for the local Game Center player.
The player must already be signed in to Game Center (GKLocalPlayer).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
CredentialCallback
|
gets |
required |
GitHubAuthProvider
¶
Credentials from GitHub OAuth access tokens (for the web flow, use
OAuthProvider("github.com")).
Methods:
| Name | Description |
|---|---|
credential |
A credential from a GitHub OAuth access token. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of GitHub sign-in. |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of GitHub sign-in.
credential
staticmethod
¶
credential(token: str) -> AuthCredential
A credential from a GitHub OAuth access token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
the GitHub access token. |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
GoogleAuthProvider
¶
Credentials from Google Sign-In tokens. For the whole flow, see
pyios_firebase.auth.google.
Methods:
| Name | Description |
|---|---|
credential |
A credential from the tokens Google Sign-In gives. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of Google sign-in. |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of Google sign-in.
credential
staticmethod
¶
credential(
id_token: str, access_token: str
) -> AuthCredential
A credential from the tokens Google Sign-In gives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_token
|
str
|
the Google ID token ( |
required |
access_token
|
str
|
the Google access token
( |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
OAuthCredential
¶
OAuthCredential(native: ObjCObject)
Bases: AuthCredential
A credential from an OAuth provider (Apple, Microsoft, Yahoo, ...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
id_token |
str | None
|
The OpenID Connect ID token, if the provider gave one. |
access_token |
str | None
|
The OAuth access token, if the provider gave one. |
secret |
str | None
|
The OAuth 1.0 token secret, if the provider gave one. |
OAuthProvider
¶
OAuthProvider(
provider_id: str,
scopes: Sequence[str] | None = None,
custom_parameters: Mapping[str, str] | None = None,
auth: Auth | None = None,
)
A generic OAuth provider: Apple, Microsoft, Yahoo, GitHub, or any OIDC / SAML provider set up in the Firebase console.
As an object, it runs the provider's web sign-in flow
(Auth.sign_in_with_provider, get_credential). The static methods
make credentials from tokens you already have.
::
microsoft = OAuthProvider("microsoft.com", scopes=["mail.read"])
Auth.auth().sign_in_with_provider(microsoft, on_signed_in)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_id
|
str
|
the provider ID, for example |
required |
scopes
|
Sequence[str] | None
|
OAuth scopes to ask for, beyond the provider's defaults. |
None
|
custom_parameters
|
Mapping[str, str] | None
|
extra OAuth parameters, for example
|
None
|
auth
|
Auth | None
|
the |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Methods:
| Name | Description |
|---|---|
get_credential |
Run the provider's web sign-in flow and give back the credential, |
credential |
A credential from tokens you already have. |
apple_credential |
A Sign in with Apple credential. For the whole flow, see |
Attributes:
| Name | Type | Description |
|---|---|---|
APPLE_PROVIDER_ID |
Final
|
The provider ID of Sign in with Apple. |
scopes |
list[str]
|
The OAuth scopes asked for (beyond the provider's defaults). |
custom_parameters |
dict[str, str]
|
Extra OAuth parameters sent to the provider. |
native |
ObjCObject
|
The |
provider_id |
str
|
The provider ID. |
APPLE_PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of Sign in with Apple.
scopes
property
writable
¶
The OAuth scopes asked for (beyond the provider's defaults).
custom_parameters
property
writable
¶
Extra OAuth parameters sent to the provider.
get_credential
¶
Run the provider's web sign-in flow and give back the credential, without signing in (for example to link it to the current user).
Shows the provider's page in an in-app browser. The app's
Info.plist needs the URL scheme Firebase documents for the provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
CredentialCallback
|
gets |
required |
credential
staticmethod
¶
credential(
provider_id: str,
id_token: str | None = None,
access_token: str | None = None,
raw_nonce: str | None = None,
) -> OAuthCredential
A credential from tokens you already have.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_id
|
str
|
the provider ID, for example |
required |
id_token
|
str | None
|
the OpenID Connect ID token, if any. |
None
|
access_token
|
str | None
|
the OAuth access token, if any. |
None
|
raw_nonce
|
str | None
|
the raw (unhashed) nonce the ID token was made for, if any. |
None
|
Returns:
| Type | Description |
|---|---|
OAuthCredential
|
An |
Raises:
| Type | Description |
|---|---|
ValueError
|
neither |
apple_credential
staticmethod
¶
apple_credential(
id_token: str,
raw_nonce: str | None,
given_name: str | None = None,
family_name: str | None = None,
) -> OAuthCredential
A Sign in with Apple credential. For the whole flow, see
pyios_firebase.auth.apple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_token
|
str
|
the identity token Apple gave (as a string). |
required |
raw_nonce
|
str | None
|
the raw nonce whose SHA-256 was sent to Apple, or |
required |
given_name
|
str | None
|
the user's given name, which Apple shares only on the first sign-in. Passing it saves it in Firebase. |
None
|
family_name
|
str | None
|
the user's family name (same as |
None
|
Returns:
| Type | Description |
|---|---|
OAuthCredential
|
An |
PhoneAuthProvider
¶
PhoneAuthProvider(auth: Auth | None = None)
Phone number sign-in: send a code by SMS, then make a credential from it.
::
phone = PhoneAuthProvider()
phone.verify_phone_number("+15555550100", on_code_sent)
# later, with the code the user typed:
credential = phone.credential(verification_id, "123456")
Real phone sign-in needs push notifications (APNs) or reCAPTCHA set up; see
Firebase's phone auth guide. With Auth.use_emulator it works without
them. Either way, the app's Info.plist needs the callback URL scheme:
the reversed client ID, or app- + the GOOGLE_APP_ID with - for :.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
Auth | None
|
the |
None
|
Methods:
| Name | Description |
|---|---|
verify_phone_number |
Send a verification code to |
verify_phone_number_for_sign_in |
Send the SMS code of an enrolled second factor, to finish a sign-in. |
credential |
A credential from the code the user received. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of phone sign-in. |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of phone sign-in.
verify_phone_number
¶
verify_phone_number(
phone_number: str,
callback: Callable[
[str | None, AuthError | None], None
],
multi_factor_session: MultiFactorSession | None = None,
) -> None
Send a verification code to phone_number by SMS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phone_number
|
str
|
the number in E.164 format, for example |
required |
callback
|
Callable[[str | None, AuthError | None], None]
|
gets |
required |
multi_factor_session
|
MultiFactorSession | None
|
to enroll the number as a second factor: the
session from |
None
|
verify_phone_number_for_sign_in
¶
verify_phone_number_for_sign_in(
hint: PhoneMultiFactorInfo,
session: MultiFactorSession,
callback: Callable[
[str | None, AuthError | None], None
],
) -> None
Send the SMS code of an enrolled second factor, to finish a sign-in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hint
|
PhoneMultiFactorInfo
|
the phone factor chosen from |
required |
session
|
MultiFactorSession
|
|
required |
callback
|
Callable[[str | None, AuthError | None], None]
|
gets |
required |
credential
¶
credential(
verification_id: str, verification_code: str
) -> AuthCredential
A credential from the code the user received.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verification_id
|
str
|
what |
required |
verification_code
|
str
|
the code from the SMS. |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
TwitterAuthProvider
¶
Credentials from Twitter (X) OAuth 1.0 tokens.
Methods:
| Name | Description |
|---|---|
credential |
A credential from a Twitter OAuth token and secret. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROVIDER_ID |
Final
|
The provider ID of Twitter sign-in. |
PROVIDER_ID
class-attribute
instance-attribute
¶
The provider ID of Twitter sign-in.
credential
staticmethod
¶
credential(token: str, secret: str) -> AuthCredential
A credential from a Twitter OAuth token and secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
the OAuth token. |
required |
secret
|
str
|
the OAuth token secret. |
required |
Returns:
| Type | Description |
|---|---|
AuthCredential
|
An |
AuthError
¶
Bases: FirebaseError
An error from Firebase Authentication (or from a sign-in sheet).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The |
email |
str | None
|
The email address the error is about, when Firebase gives one (for |
updated_credential |
AuthCredential | None
|
With |
resolver |
MultiFactorResolver | None
|
With |
cancelled |
bool
|
True when the user closed a sign-in sheet (Google, Apple, web |
message |
str
|
A sentence to show to the user, when the library has a better one than |
name
instance-attribute
¶
The AuthErrorCode name of code (for example "WRONG_PASSWORD"),
or "" for errors from other domains.
email
instance-attribute
¶
The email address the error is about, when Firebase gives one (for
example with ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL).
updated_credential
instance-attribute
¶
updated_credential: AuthCredential | None
With ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL and
CREDENTIAL_ALREADY_IN_USE: a credential to sign in with instead.
resolver
instance-attribute
¶
resolver: MultiFactorResolver | None
With SECOND_FACTOR_REQUIRED: finishes the sign-in with a second
factor (see pyios_firebase.auth.multi_factor).
cancelled
instance-attribute
¶
True when the user closed a sign-in sheet (Google, Apple, web providers): not a failure to report.
message
instance-attribute
¶
A sentence to show to the user, when the library has a better one than
description (Apple sign-in); otherwise "".
AuthErrorCode
¶
The error.code values of Firebase Authentication errors.
Generated from FIRAuthErrorCode in the Firebase iOS SDK (13.1.1). The
numbers are fixed in the SDK; check them when you update it.
Attributes:
| Name | Type | Description |
|---|---|---|
INVALID_CUSTOM_TOKEN |
Final
|
Indicates a validation error with the custom token. |
CUSTOM_TOKEN_MISMATCH |
Final
|
Indicates the service account and the API key belong to different projects. |
INVALID_CREDENTIAL |
Final
|
Indicates the IDP token or requestUri is invalid. |
USER_DISABLED |
Final
|
Indicates the user's account is disabled on the server. |
OPERATION_NOT_ALLOWED |
Final
|
Indicates the administrator disabled sign in with the specified identity provider. |
EMAIL_ALREADY_IN_USE |
Final
|
Indicates the email used to attempt a sign up is already in use. |
INVALID_EMAIL |
Final
|
Indicates the email is invalid. |
WRONG_PASSWORD |
Final
|
Indicates the user attempted sign in with a wrong password. |
TOO_MANY_REQUESTS |
Final
|
Indicates that too many requests were made to a server method. |
USER_NOT_FOUND |
Final
|
Indicates the user account was not found. |
ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL |
Final
|
Indicates account linking is required. |
REQUIRES_RECENT_LOGIN |
Final
|
Indicates the user has attempted to change email or password more than 5 minutes after signing in. |
PROVIDER_ALREADY_LINKED |
Final
|
Indicates an attempt to link a provider to which the account is already linked. |
NO_SUCH_PROVIDER |
Final
|
Indicates an attempt to unlink a provider that is not linked. |
INVALID_USER_TOKEN |
Final
|
Indicates user's saved auth credential is invalid the user needs to sign in again. |
NETWORK_ERROR |
Final
|
Indicates a network error occurred (such as a timeout interrupted connection or unreachable host). |
USER_TOKEN_EXPIRED |
Final
|
Indicates the saved token has expired for example the user may have changed account password on another device. |
INVALID_API_KEY |
Final
|
Indicates an invalid API key was supplied in the request. |
USER_MISMATCH |
Final
|
Indicates that an attempt was made to reauthenticate with a user which is not the current user. |
CREDENTIAL_ALREADY_IN_USE |
Final
|
Indicates an attempt to link with a credential that has already been linked with a different Firebase account. |
WEAK_PASSWORD |
Final
|
Indicates an attempt to set a password that is considered too weak. |
APP_NOT_AUTHORIZED |
Final
|
Indicates the App is not authorized to use Firebase Authentication with the provided API Key. |
EXPIRED_ACTION_CODE |
Final
|
Indicates the OOB code is expired. |
INVALID_ACTION_CODE |
Final
|
Indicates the OOB code is invalid. |
INVALID_MESSAGE_PAYLOAD |
Final
|
Indicates that there are invalid parameters in the payload during a 'send password reset email' attempt. |
INVALID_SENDER |
Final
|
Indicates that the sender email is invalid during a 'send password reset email' attempt. |
INVALID_RECIPIENT_EMAIL |
Final
|
Indicates that the recipient email is invalid. |
MISSING_EMAIL |
Final
|
Indicates that an email address was expected but one was not provided. |
MISSING_IOS_BUNDLE_ID |
Final
|
Indicates that the iOS bundle ID is missing when a iOS App Store ID is provided. |
MISSING_ANDROID_PACKAGE_NAME |
Final
|
Indicates that the android package name is missing when the |
UNAUTHORIZED_DOMAIN |
Final
|
Indicates that the domain specified in the continue URL is not allowlisted in the Firebase console. |
INVALID_CONTINUE_URI |
Final
|
Indicates that the domain specified in the continue URI is not valid. |
MISSING_CONTINUE_URI |
Final
|
Indicates that a continue URI was not provided in a request to the backend which requires one. |
MISSING_PHONE_NUMBER |
Final
|
Indicates that a phone number was not provided in a call to |
INVALID_PHONE_NUMBER |
Final
|
Indicates that an invalid phone number was provided in a call to |
MISSING_VERIFICATION_CODE |
Final
|
Indicates that the phone auth credential was created with an empty verification code. |
INVALID_VERIFICATION_CODE |
Final
|
Indicates that an invalid verification code was used in the verifyPhoneNumber request. |
MISSING_VERIFICATION_ID |
Final
|
Indicates that the phone auth credential was created with an empty verification ID. |
INVALID_VERIFICATION_ID |
Final
|
Indicates that an invalid verification ID was used in the verifyPhoneNumber request. |
MISSING_APP_CREDENTIAL |
Final
|
Indicates that the APNS device token is missing in the verifyClient request. |
INVALID_APP_CREDENTIAL |
Final
|
Indicates that an invalid APNS device token was used in the verifyClient request. |
SESSION_EXPIRED |
Final
|
Indicates that the SMS code has expired. |
QUOTA_EXCEEDED |
Final
|
Indicates that the quota of SMS messages for a given project has been exceeded. |
MISSING_APP_TOKEN |
Final
|
Indicates that the APNs device token could not be obtained. |
NOTIFICATION_NOT_FORWARDED |
Final
|
Indicates that the app fails to forward remote notification to FIRAuth. |
APP_NOT_VERIFIED |
Final
|
Indicates that the app could not be verified by Firebase during phone number authentication. |
CAPTCHA_CHECK_FAILED |
Final
|
Indicates that the reCAPTCHA token is not valid. |
WEB_CONTEXT_ALREADY_PRESENTED |
Final
|
Indicates that an attempt was made to present a new web context while one was already being presented. |
WEB_CONTEXT_CANCELLED |
Final
|
Indicates that the URL presentation was cancelled prematurely by the user. |
APP_VERIFICATION_USER_INTERACTION_FAILURE |
Final
|
Indicates a general failure during the app verification flow. |
INVALID_CLIENT_ID |
Final
|
Indicates that the clientID used to invoke a web flow is invalid. |
WEB_NETWORK_REQUEST_FAILED |
Final
|
Indicates that a network request within a SFSafariViewController or WKWebView failed. |
WEB_INTERNAL_ERROR |
Final
|
Indicates that an internal error occurred within a SFSafariViewController or WKWebView. |
WEB_SIGN_IN_USER_INTERACTION_FAILURE |
Final
|
Indicates a general failure during a web sign-in flow. |
LOCAL_PLAYER_NOT_AUTHENTICATED |
Final
|
Indicates that the local player was not authenticated prior to attempting Game Center signin. |
NULL_USER |
Final
|
Indicates that a non-null user was expected as an argument to the operation but a null user was provided. |
INVALID_PROVIDER_ID |
Final
|
Represents the error code for when the given provider id for a web operation is invalid. |
TENANT_ID_MISMATCH |
Final
|
Represents the error code for when an attempt is made to update the current user with a tenantId that differs from the current FirebaseAuth instance's tenantId. |
UNSUPPORTED_TENANT_OPERATION |
Final
|
Represents the error code for when a request is made to the backend with an associated tenant ID for an operation that does not support multi-tenancy. |
INVALID_HOSTING_LINK_DOMAIN |
Final
|
Indicates that the provided Firebase Hosting Link domain is not owned by the current project. |
REJECTED_CREDENTIAL |
Final
|
Indicates that the credential is rejected because it's malformed or mismatching. |
GAME_KIT_NOT_LINKED |
Final
|
Indicates that the GameKit framework is not linked prior to attempting Game Center signin. |
SECOND_FACTOR_REQUIRED |
Final
|
Indicates that the second factor is required for signin. |
MISSING_MULTI_FACTOR_SESSION |
Final
|
Indicates that the multi factor session is missing. |
MISSING_MULTI_FACTOR_INFO |
Final
|
Indicates that the multi factor info is missing. |
INVALID_MULTI_FACTOR_SESSION |
Final
|
Indicates that the multi factor session is invalid. |
MULTI_FACTOR_INFO_NOT_FOUND |
Final
|
Indicates that the multi factor info is not found. |
ADMIN_RESTRICTED_OPERATION |
Final
|
Indicates that the operation is admin restricted. |
UNVERIFIED_EMAIL |
Final
|
Indicates that the email is required for verification. |
SECOND_FACTOR_ALREADY_ENROLLED |
Final
|
Indicates that the second factor is already enrolled. |
MAXIMUM_SECOND_FACTOR_COUNT_EXCEEDED |
Final
|
Indicates that the maximum second factor count is exceeded. |
UNSUPPORTED_FIRST_FACTOR |
Final
|
Indicates that the first factor is not supported. |
EMAIL_CHANGE_NEEDS_VERIFICATION |
Final
|
Indicates that the a verified email is required to changed to. |
MISSING_CLIENT_IDENTIFIER |
Final
|
Indicates that the request does not contain a client identifier. |
MISSING_OR_INVALID_NONCE |
Final
|
Indicates that the nonce is missing or invalid. |
BLOCKING_CLOUD_FUNCTION_ERROR |
Final
|
Raised when a Cloud Function returns a blocking error. |
RECAPTCHA_NOT_ENABLED |
Final
|
Indicates that reCAPTCHA Enterprise integration is not enabled for this project. |
MISSING_RECAPTCHA_TOKEN |
Final
|
Indicates that the reCAPTCHA token is missing from the backend request. |
INVALID_RECAPTCHA_TOKEN |
Final
|
Indicates that the reCAPTCHA token sent with the backend request is invalid. |
INVALID_RECAPTCHA_ACTION |
Final
|
Indicates that the requested reCAPTCHA action is invalid. |
MISSING_CLIENT_TYPE |
Final
|
Indicates that the client type is missing from the request. |
MISSING_RECAPTCHA_VERSION |
Final
|
Indicates that the reCAPTCHA version is missing from the request. |
INVALID_RECAPTCHA_VERSION |
Final
|
Indicates that the reCAPTCHA version sent to the backend is invalid. |
INVALID_REQ_TYPE |
Final
|
Indicates that the request type sent to the backend is invalid. |
RECAPTCHA_SDK_NOT_LINKED |
Final
|
Indicates that the reCAPTCHA SDK is not linked to the app. |
RECAPTCHA_SITE_KEY_MISSING |
Final
|
Indicates that the reCAPTCHA SDK site key wasn't found. |
RECAPTCHA_ACTION_CREATION_FAILED |
Final
|
Indicates that the reCAPTCHA SDK actions class failed to create. |
PASSWORD_DOES_NOT_MEET_REQUIREMENTS |
Final
|
Indicates that the password does not meet the project's password policy. |
KEYCHAIN_ERROR |
Final
|
Indicates an error occurred while attempting to access the keychain. |
INTERNAL_ERROR |
Final
|
Indicates an internal error occurred. |
MALFORMED_JWT |
Final
|
Raised when a JWT fails to parse correctly. |
INVALID_CUSTOM_TOKEN
class-attribute
instance-attribute
¶
Indicates a validation error with the custom token.
CUSTOM_TOKEN_MISMATCH
class-attribute
instance-attribute
¶
Indicates the service account and the API key belong to different projects.
INVALID_CREDENTIAL
class-attribute
instance-attribute
¶
Indicates the IDP token or requestUri is invalid.
USER_DISABLED
class-attribute
instance-attribute
¶
Indicates the user's account is disabled on the server.
OPERATION_NOT_ALLOWED
class-attribute
instance-attribute
¶
Indicates the administrator disabled sign in with the specified identity provider.
EMAIL_ALREADY_IN_USE
class-attribute
instance-attribute
¶
Indicates the email used to attempt a sign up is already in use.
INVALID_EMAIL
class-attribute
instance-attribute
¶
Indicates the email is invalid.
WRONG_PASSWORD
class-attribute
instance-attribute
¶
Indicates the user attempted sign in with a wrong password.
TOO_MANY_REQUESTS
class-attribute
instance-attribute
¶
Indicates that too many requests were made to a server method.
USER_NOT_FOUND
class-attribute
instance-attribute
¶
Indicates the user account was not found.
ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL
class-attribute
instance-attribute
¶
Indicates account linking is required.
REQUIRES_RECENT_LOGIN
class-attribute
instance-attribute
¶
Indicates the user has attempted to change email or password more than 5 minutes after signing in.
PROVIDER_ALREADY_LINKED
class-attribute
instance-attribute
¶
Indicates an attempt to link a provider to which the account is already linked.
NO_SUCH_PROVIDER
class-attribute
instance-attribute
¶
Indicates an attempt to unlink a provider that is not linked.
INVALID_USER_TOKEN
class-attribute
instance-attribute
¶
Indicates user's saved auth credential is invalid the user needs to sign in again.
NETWORK_ERROR
class-attribute
instance-attribute
¶
Indicates a network error occurred (such as a timeout interrupted connection or unreachable host).
USER_TOKEN_EXPIRED
class-attribute
instance-attribute
¶
Indicates the saved token has expired for example the user may have changed account password on another device.
INVALID_API_KEY
class-attribute
instance-attribute
¶
Indicates an invalid API key was supplied in the request.
USER_MISMATCH
class-attribute
instance-attribute
¶
Indicates that an attempt was made to reauthenticate with a user which is not the current user.
CREDENTIAL_ALREADY_IN_USE
class-attribute
instance-attribute
¶
Indicates an attempt to link with a credential that has already been linked with a different Firebase account.
WEAK_PASSWORD
class-attribute
instance-attribute
¶
Indicates an attempt to set a password that is considered too weak.
APP_NOT_AUTHORIZED
class-attribute
instance-attribute
¶
Indicates the App is not authorized to use Firebase Authentication with the provided API Key.
EXPIRED_ACTION_CODE
class-attribute
instance-attribute
¶
Indicates the OOB code is expired.
INVALID_ACTION_CODE
class-attribute
instance-attribute
¶
Indicates the OOB code is invalid.
INVALID_MESSAGE_PAYLOAD
class-attribute
instance-attribute
¶
Indicates that there are invalid parameters in the payload during a 'send password reset email' attempt.
INVALID_SENDER
class-attribute
instance-attribute
¶
Indicates that the sender email is invalid during a 'send password reset email' attempt.
INVALID_RECIPIENT_EMAIL
class-attribute
instance-attribute
¶
Indicates that the recipient email is invalid.
MISSING_EMAIL
class-attribute
instance-attribute
¶
Indicates that an email address was expected but one was not provided.
MISSING_IOS_BUNDLE_ID
class-attribute
instance-attribute
¶
Indicates that the iOS bundle ID is missing when a iOS App Store ID is provided.
MISSING_ANDROID_PACKAGE_NAME
class-attribute
instance-attribute
¶
Indicates that the android package name is missing when the androidInstallApp flag is set to true.
UNAUTHORIZED_DOMAIN
class-attribute
instance-attribute
¶
Indicates that the domain specified in the continue URL is not allowlisted in the Firebase console.
INVALID_CONTINUE_URI
class-attribute
instance-attribute
¶
Indicates that the domain specified in the continue URI is not valid.
MISSING_CONTINUE_URI
class-attribute
instance-attribute
¶
Indicates that a continue URI was not provided in a request to the backend which requires one.
MISSING_PHONE_NUMBER
class-attribute
instance-attribute
¶
Indicates that a phone number was not provided in a call to verifyPhoneNumber:completion:.
INVALID_PHONE_NUMBER
class-attribute
instance-attribute
¶
Indicates that an invalid phone number was provided in a call to verifyPhoneNumber:completion:.
MISSING_VERIFICATION_CODE
class-attribute
instance-attribute
¶
Indicates that the phone auth credential was created with an empty verification code.
INVALID_VERIFICATION_CODE
class-attribute
instance-attribute
¶
Indicates that an invalid verification code was used in the verifyPhoneNumber request.
MISSING_VERIFICATION_ID
class-attribute
instance-attribute
¶
Indicates that the phone auth credential was created with an empty verification ID.
INVALID_VERIFICATION_ID
class-attribute
instance-attribute
¶
Indicates that an invalid verification ID was used in the verifyPhoneNumber request.
MISSING_APP_CREDENTIAL
class-attribute
instance-attribute
¶
Indicates that the APNS device token is missing in the verifyClient request.
INVALID_APP_CREDENTIAL
class-attribute
instance-attribute
¶
Indicates that an invalid APNS device token was used in the verifyClient request.
SESSION_EXPIRED
class-attribute
instance-attribute
¶
Indicates that the SMS code has expired.
QUOTA_EXCEEDED
class-attribute
instance-attribute
¶
Indicates that the quota of SMS messages for a given project has been exceeded.
MISSING_APP_TOKEN
class-attribute
instance-attribute
¶
Indicates that the APNs device token could not be obtained.
NOTIFICATION_NOT_FORWARDED
class-attribute
instance-attribute
¶
Indicates that the app fails to forward remote notification to FIRAuth.
APP_NOT_VERIFIED
class-attribute
instance-attribute
¶
Indicates that the app could not be verified by Firebase during phone number authentication.
CAPTCHA_CHECK_FAILED
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA token is not valid.
WEB_CONTEXT_ALREADY_PRESENTED
class-attribute
instance-attribute
¶
Indicates that an attempt was made to present a new web context while one was already being presented.
WEB_CONTEXT_CANCELLED
class-attribute
instance-attribute
¶
Indicates that the URL presentation was cancelled prematurely by the user.
APP_VERIFICATION_USER_INTERACTION_FAILURE
class-attribute
instance-attribute
¶
Indicates a general failure during the app verification flow.
INVALID_CLIENT_ID
class-attribute
instance-attribute
¶
Indicates that the clientID used to invoke a web flow is invalid.
WEB_NETWORK_REQUEST_FAILED
class-attribute
instance-attribute
¶
Indicates that a network request within a SFSafariViewController or WKWebView failed.
WEB_INTERNAL_ERROR
class-attribute
instance-attribute
¶
Indicates that an internal error occurred within a SFSafariViewController or WKWebView.
WEB_SIGN_IN_USER_INTERACTION_FAILURE
class-attribute
instance-attribute
¶
Indicates a general failure during a web sign-in flow.
LOCAL_PLAYER_NOT_AUTHENTICATED
class-attribute
instance-attribute
¶
Indicates that the local player was not authenticated prior to attempting Game Center signin.
NULL_USER
class-attribute
instance-attribute
¶
Indicates that a non-null user was expected as an argument to the operation but a null user was provided.
INVALID_PROVIDER_ID
class-attribute
instance-attribute
¶
Represents the error code for when the given provider id for a web operation is invalid.
TENANT_ID_MISMATCH
class-attribute
instance-attribute
¶
Represents the error code for when an attempt is made to update the current user with a tenantId that differs from the current FirebaseAuth instance's tenantId.
UNSUPPORTED_TENANT_OPERATION
class-attribute
instance-attribute
¶
Represents the error code for when a request is made to the backend with an associated tenant ID for an operation that does not support multi-tenancy.
INVALID_HOSTING_LINK_DOMAIN
class-attribute
instance-attribute
¶
Indicates that the provided Firebase Hosting Link domain is not owned by the current project.
REJECTED_CREDENTIAL
class-attribute
instance-attribute
¶
Indicates that the credential is rejected because it's malformed or mismatching.
GAME_KIT_NOT_LINKED
class-attribute
instance-attribute
¶
Indicates that the GameKit framework is not linked prior to attempting Game Center signin.
SECOND_FACTOR_REQUIRED
class-attribute
instance-attribute
¶
Indicates that the second factor is required for signin.
MISSING_MULTI_FACTOR_SESSION
class-attribute
instance-attribute
¶
Indicates that the multi factor session is missing.
MISSING_MULTI_FACTOR_INFO
class-attribute
instance-attribute
¶
Indicates that the multi factor info is missing.
INVALID_MULTI_FACTOR_SESSION
class-attribute
instance-attribute
¶
Indicates that the multi factor session is invalid.
MULTI_FACTOR_INFO_NOT_FOUND
class-attribute
instance-attribute
¶
Indicates that the multi factor info is not found.
ADMIN_RESTRICTED_OPERATION
class-attribute
instance-attribute
¶
Indicates that the operation is admin restricted.
UNVERIFIED_EMAIL
class-attribute
instance-attribute
¶
Indicates that the email is required for verification.
SECOND_FACTOR_ALREADY_ENROLLED
class-attribute
instance-attribute
¶
Indicates that the second factor is already enrolled.
MAXIMUM_SECOND_FACTOR_COUNT_EXCEEDED
class-attribute
instance-attribute
¶
Indicates that the maximum second factor count is exceeded.
UNSUPPORTED_FIRST_FACTOR
class-attribute
instance-attribute
¶
Indicates that the first factor is not supported.
EMAIL_CHANGE_NEEDS_VERIFICATION
class-attribute
instance-attribute
¶
Indicates that the a verified email is required to changed to.
MISSING_CLIENT_IDENTIFIER
class-attribute
instance-attribute
¶
Indicates that the request does not contain a client identifier.
MISSING_OR_INVALID_NONCE
class-attribute
instance-attribute
¶
Indicates that the nonce is missing or invalid.
BLOCKING_CLOUD_FUNCTION_ERROR
class-attribute
instance-attribute
¶
Raised when a Cloud Function returns a blocking error.
RECAPTCHA_NOT_ENABLED
class-attribute
instance-attribute
¶
Indicates that reCAPTCHA Enterprise integration is not enabled for this project.
MISSING_RECAPTCHA_TOKEN
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA token is missing from the backend request.
INVALID_RECAPTCHA_TOKEN
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA token sent with the backend request is invalid.
INVALID_RECAPTCHA_ACTION
class-attribute
instance-attribute
¶
Indicates that the requested reCAPTCHA action is invalid.
MISSING_CLIENT_TYPE
class-attribute
instance-attribute
¶
Indicates that the client type is missing from the request.
MISSING_RECAPTCHA_VERSION
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA version is missing from the request.
INVALID_RECAPTCHA_VERSION
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA version sent to the backend is invalid.
INVALID_REQ_TYPE
class-attribute
instance-attribute
¶
Indicates that the request type sent to the backend is invalid.
RECAPTCHA_SDK_NOT_LINKED
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA SDK is not linked to the app.
RECAPTCHA_SITE_KEY_MISSING
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA SDK site key wasn't found.
RECAPTCHA_ACTION_CREATION_FAILED
class-attribute
instance-attribute
¶
Indicates that the reCAPTCHA SDK actions class failed to create.
PASSWORD_DOES_NOT_MEET_REQUIREMENTS
class-attribute
instance-attribute
¶
Indicates that the password does not meet the project's password policy.
KEYCHAIN_ERROR
class-attribute
instance-attribute
¶
Indicates an error occurred while attempting to access the keychain.
INTERNAL_ERROR
class-attribute
instance-attribute
¶
Indicates an internal error occurred.
MALFORMED_JWT
class-attribute
instance-attribute
¶
Raised when a JWT fails to parse correctly.
MultiFactor
¶
MultiFactor(native: ObjCObject)
A user's second factors. Get it with User.multi_factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Methods:
| Name | Description |
|---|---|
get_session |
Start an enrollment: get a session for SMS verification or a TOTP secret. |
enroll |
Enroll a second factor. |
unenroll |
Remove a second factor. |
Attributes:
| Name | Type | Description |
|---|---|---|
enrolled_factors |
list[MultiFactorInfo]
|
The enrolled second factors ( |
enrolled_factors
property
¶
enrolled_factors: list[MultiFactorInfo]
The enrolled second factors (PhoneMultiFactorInfo for SMS).
get_session
¶
get_session(
callback: Callable[
[MultiFactorSession | None, AuthError | None], None
],
) -> None
Start an enrollment: get a session for SMS verification or a TOTP secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[MultiFactorSession | None, AuthError | None], None]
|
gets |
required |
enroll
¶
enroll(
assertion: MultiFactorAssertion,
display_name: str | None = None,
callback: ErrorCallback | None = None,
) -> None
Enroll a second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assertion
|
MultiFactorAssertion
|
from |
required |
display_name
|
str | None
|
a name to show in sign-in hints, for example "Work phone". |
None
|
callback
|
ErrorCallback | None
|
gets |
None
|
unenroll
¶
unenroll(
factor: MultiFactorInfo | str,
callback: ErrorCallback | None = None,
) -> None
Remove a second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factor
|
MultiFactorInfo | str
|
the factor, or its |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
MultiFactorAssertion
¶
MultiFactorAssertion(native: ObjCObject)
Proof of a second factor, for MultiFactor.enroll or
MultiFactorResolver.resolve_sign_in. Make it with
PhoneMultiFactorGenerator or TOTPMultiFactorGenerator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
factor_id |
str
|
|
MultiFactorInfo
¶
MultiFactorInfo(native: ObjCObject)
One enrolled second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
uid |
str
|
The factor's ID (its enrollment ID for TOTP sign-in). |
factor_id |
str
|
|
display_name |
str | None
|
The name given at enrollment, or |
enrollment_date |
datetime | None
|
When the factor was enrolled (UTC). |
MultiFactorResolver
¶
MultiFactorResolver(native: ObjCObject)
Finishes a sign-in that needs a second factor. Get it from
AuthError.resolver when error.code == AuthErrorCode.SECOND_FACTOR_REQUIRED.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Methods:
| Name | Description |
|---|---|
resolve_sign_in |
Finish the sign-in with a second factor. |
Attributes:
| Name | Type | Description |
|---|---|---|
hints |
list[MultiFactorInfo]
|
The user's enrolled factors: let them choose one. |
session |
MultiFactorSession
|
The session proving the first factor: pass it to SMS verification. |
session
property
¶
session: MultiFactorSession
The session proving the first factor: pass it to SMS verification.
resolve_sign_in
¶
resolve_sign_in(
assertion: MultiFactorAssertion,
callback: Callable[
[AuthDataResult | None, AuthError | None], None
]
| None = None,
) -> None
Finish the sign-in with a second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assertion
|
MultiFactorAssertion
|
from |
required |
callback
|
Callable[[AuthDataResult | None, AuthError | None], None] | None
|
gets |
None
|
MultiFactorSession
¶
MultiFactorSession(native: ObjCObject)
Proves the first factor was just completed (or that the user is signed
in, for enrollment). Pass it to SMS verification or generate_secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
PhoneMultiFactorGenerator
¶
Make SMS second-factor assertions.
Methods:
| Name | Description |
|---|---|
assertion |
An assertion from a phone credential. |
assertion
staticmethod
¶
assertion(
credential: AuthCredential,
) -> MultiFactorAssertion
An assertion from a phone credential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
AuthCredential
|
from |
required |
Returns:
| Type | Description |
|---|---|
MultiFactorAssertion
|
A |
PhoneMultiFactorInfo
¶
PhoneMultiFactorInfo(native: ObjCObject)
Bases: MultiFactorInfo
An enrolled SMS second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
phone_number |
str
|
The phone number, usually masked in sign-in hints ( |
phone_number
property
¶
The phone number, usually masked in sign-in hints (+*******0100).
TOTPMultiFactorGenerator
¶
Make TOTP (authenticator app) secrets and assertions.
Methods:
| Name | Description |
|---|---|
generate_secret |
Make a new TOTP secret for enrollment. |
assertion_for_enrollment |
An assertion to enroll the authenticator app. |
assertion_for_sign_in |
An assertion to finish a sign-in with the authenticator app. |
generate_secret
staticmethod
¶
generate_secret(
session: MultiFactorSession,
callback: Callable[
[TOTPSecret | None, AuthError | None], None
],
) -> None
Make a new TOTP secret for enrollment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
MultiFactorSession
|
from |
required |
callback
|
Callable[[TOTPSecret | None, AuthError | None], None]
|
gets |
required |
assertion_for_enrollment
staticmethod
¶
assertion_for_enrollment(
secret: TOTPSecret, one_time_password: str
) -> MultiFactorAssertion
An assertion to enroll the authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret
|
TOTPSecret
|
from |
required |
one_time_password
|
str
|
the 6-digit code the app shows now. |
required |
Returns:
| Type | Description |
|---|---|
MultiFactorAssertion
|
A |
assertion_for_sign_in
staticmethod
¶
assertion_for_sign_in(
enrollment_id: str, one_time_password: str
) -> MultiFactorAssertion
An assertion to finish a sign-in with the authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enrollment_id
|
str
|
the |
required |
one_time_password
|
str
|
the 6-digit code the app shows now. |
required |
Returns:
| Type | Description |
|---|---|
MultiFactorAssertion
|
A |
TOTPSecret
¶
TOTPSecret(native: ObjCObject)
A new TOTP secret, to show to the user while they set up their authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Methods:
| Name | Description |
|---|---|
shared_secret_key |
The secret, to type into an authenticator app by hand. |
generate_qr_code_url |
An |
open_in_otp_app |
Open the URL in an installed authenticator app (if there is one). |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
shared_secret_key
¶
The secret, to type into an authenticator app by hand.
generate_qr_code_url
¶
An otpauth:// URL, to show as a QR code for an authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_name
|
str
|
shown in the authenticator app, usually the email. |
required |
issuer
|
str
|
your app's name, shown in the authenticator app. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The URL. |
open_in_otp_app
¶
Open the URL in an installed authenticator app (if there is one).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qr_code_url
|
str
|
from |
required |
ActionCodeInfo
dataclass
¶
What Auth.check_action_code learned about an email action code.
Methods:
| Name | Description |
|---|---|
from_native |
Copy a native |
Attributes:
| Name | Type | Description |
|---|---|---|
operation |
int
|
An |
email |
str
|
The email address the code is for. |
previous_email |
str | None
|
For |
operation
instance-attribute
¶
An ActionCodeOperation value.
Firebase iOS SDK 13.1.1 only recognises request types in camel case
("resetPassword"); a server that sends "PASSWORD_RESET", as the
Auth emulator does, gives UNKNOWN. Do not rely on it alone.
previous_email
instance-attribute
¶
For RECOVER_EMAIL / VERIFY_AND_CHANGE_EMAIL: the old address.
from_native
classmethod
¶
from_native(native: ObjCObject) -> ActionCodeInfo
Copy a native FIRActionCodeInfo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the |
required |
ActionCodeOperation
¶
What an email action code (link) is for. The values of
ActionCodeInfo.operation.
ActionCodeSettings
dataclass
¶
ActionCodeSettings(
url: str | None = None,
handle_code_in_app: bool = False,
ios_bundle_id: str | None = None,
android_package_name: str | None = None,
android_install_if_not_available: bool = False,
android_minimum_version: str | None = None,
link_domain: str | None = None,
)
Where email links (password reset, verification, sign-in) lead.
::
ActionCodeSettings(
url="https://example.com/finish-sign-in",
handle_code_in_app=True,
ios_bundle_id="com.example.app",
)
Methods:
| Name | Description |
|---|---|
to_native |
Make the native |
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str | None
|
The continue URL: where the user lands after the action. Its domain must |
handle_code_in_app |
bool
|
True to open the link in the app (required for email link sign-in). |
ios_bundle_id |
str | None
|
The iOS app to open the link in. |
android_package_name |
str | None
|
The Android app to open the link in. |
android_install_if_not_available |
bool
|
Offer to install the Android app if it is missing. |
android_minimum_version |
str | None
|
The minimum Android app version that can handle the link. |
link_domain |
str | None
|
A custom Firebase Hosting domain for the link. |
url
class-attribute
instance-attribute
¶
The continue URL: where the user lands after the action. Its domain must be authorized in the Firebase console.
handle_code_in_app
class-attribute
instance-attribute
¶
True to open the link in the app (required for email link sign-in).
ios_bundle_id
class-attribute
instance-attribute
¶
The iOS app to open the link in.
android_package_name
class-attribute
instance-attribute
¶
The Android app to open the link in.
android_install_if_not_available
class-attribute
instance-attribute
¶
Offer to install the Android app if it is missing.
android_minimum_version
class-attribute
instance-attribute
¶
The minimum Android app version that can handle the link.
link_domain
class-attribute
instance-attribute
¶
A custom Firebase Hosting domain for the link.
ActionCodeURL
dataclass
¶
ActionCodeURL(
operation: int,
code: str | None,
continue_url: str | None,
api_key: str | None,
language_code: str | None,
)
The parts of an email action link (password reset, verification, sign-in), read without calling the server.
Use it to get the continue_url back, with the state you put in it
("Passing State in Email Actions")::
info = ActionCodeURL.from_link(link)
if info is not None and info.continue_url:
state = urllib.parse.parse_qs(urllib.parse.urlsplit(info.continue_url).query)
Parsed in Python: Firebase iOS SDK 13.1.1 decodes the link's query before
splitting it, which cuts a continue URL at its own & and loses state.
Methods:
| Name | Description |
|---|---|
from_link |
Parse an action link. |
Attributes:
| Name | Type | Description |
|---|---|---|
operation |
int
|
An |
code |
str | None
|
The action code ( |
continue_url |
str | None
|
The continue URL given in |
api_key |
str | None
|
The Firebase API key in the link. |
language_code |
str | None
|
The language of the email, or |
code
instance-attribute
¶
The action code (oobCode): pass it to apply_action_code,
confirm_password_reset, ...
continue_url
instance-attribute
¶
The continue URL given in ActionCodeSettings.url, with its state.
from_link
classmethod
¶
from_link(link: str) -> ActionCodeURL | None
Parse an action link.
Links wrapped in another link's link parameter (as Firebase Hosting
and Dynamic Links deliver them) are unwrapped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
str
|
the full link from the email (or the URL the app was opened with). |
required |
Returns:
| Type | Description |
|---|---|
ActionCodeURL | None
|
An |
ActionCodeURL | None
|
|
AdditionalUserInfo
dataclass
¶
AdditionalUserInfo(
provider_id: str,
is_new_user: bool,
username: str | None,
profile: dict[str, Any],
)
Provider details from one sign-in.
Methods:
| Name | Description |
|---|---|
from_native |
Copy a native |
Attributes:
| Name | Type | Description |
|---|---|---|
provider_id |
str
|
The provider used for this sign-in. |
is_new_user |
bool
|
True if this sign-in created the account. |
username |
str | None
|
The username at the provider (GitHub, Twitter), or |
profile |
dict[str, Any]
|
The provider's profile data (for example Google's |
username
instance-attribute
¶
The username at the provider (GitHub, Twitter), or None.
profile
instance-attribute
¶
The provider's profile data (for example Google's given_name).
from_native
classmethod
¶
from_native(native: ObjCObject) -> AdditionalUserInfo
Copy a native FIRAdditionalUserInfo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the |
required |
AuthDataResult
¶
AuthDataResult(native: ObjCObject)
The result of a sign-in, link or re-authentication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
user |
User
|
The signed-in (or linked) user. |
additional_user_info |
AdditionalUserInfo | None
|
Provider details from this sign-in, or |
credential |
OAuthCredential | None
|
The OAuth credential the provider gave (OAuth providers only), or |
additional_user_info
property
¶
additional_user_info: AdditionalUserInfo | None
Provider details from this sign-in, or None.
credential
property
¶
credential: OAuthCredential | None
The OAuth credential the provider gave (OAuth providers only), or
None. Holds the provider's own access / ID tokens.
IDTokenResult
dataclass
¶
IDTokenResult(
token: str,
claims: dict[str, Any],
expiration_date: datetime,
issued_at_date: datetime,
auth_date: datetime,
sign_in_provider: str,
sign_in_second_factor: str | None,
)
A Firebase ID token and what it says.
Methods:
| Name | Description |
|---|---|
from_native |
Copy a native |
Attributes:
| Name | Type | Description |
|---|---|---|
token |
str
|
The ID token (a JWT). Send it to your backend to prove who the user is. |
claims |
dict[str, Any]
|
All the token's claims, including custom claims set by your backend. |
expiration_date |
datetime
|
When the token expires (UTC). |
issued_at_date |
datetime
|
When the token was issued (UTC). |
auth_date |
datetime
|
When the user signed in (UTC). |
sign_in_provider |
str
|
The provider used to sign in, for example |
sign_in_second_factor |
str | None
|
The second factor used, for multi-factor sign-in, or |
token
instance-attribute
¶
The ID token (a JWT). Send it to your backend to prove who the user is.
claims
instance-attribute
¶
All the token's claims, including custom claims set by your backend.
sign_in_provider
instance-attribute
¶
The provider used to sign in, for example "password" or "anonymous".
sign_in_second_factor
instance-attribute
¶
The second factor used, for multi-factor sign-in, or None.
from_native
classmethod
¶
from_native(native: ObjCObject) -> IDTokenResult
Copy a native FIRAuthTokenResult.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the |
required |
UserInfo
¶
UserInfo(native: ObjCObject)
A user's profile at one provider (an entry of User.provider_data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
provider_id |
str
|
The provider ID, for example |
uid |
str
|
The user's ID at that provider (not the Firebase uid). |
display_name |
str | None
|
The name at that provider, or |
email |
str | None
|
The email address at that provider, or |
phone_number |
str | None
|
The phone number at that provider, or |
photo_url |
str | None
|
The profile photo URL at that provider, or |
UserMetadata
dataclass
¶
When the user was created and last signed in.
Methods:
| Name | Description |
|---|---|
from_native |
Copy a native |
Attributes:
| Name | Type | Description |
|---|---|---|
creation_date |
datetime | None
|
When the account was created (UTC). |
last_sign_in_date |
datetime | None
|
When the user last signed in (UTC). |
creation_date
instance-attribute
¶
When the account was created (UTC).
last_sign_in_date
instance-attribute
¶
When the user last signed in (UTC).
from_native
classmethod
¶
from_native(native: ObjCObject) -> UserMetadata
Copy a native FIRUserMetadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the |
required |
User
¶
User(user: ObjCObject | None = None)
A Firebase user: the signed-in one by default.
User() reads the user who is signed in now. When nobody is,
is_signed_in is False and the profile properties are None; the
account methods need a signed-in user.
Get users from Auth.current_user, sign-in results and auth state
listeners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
ObjCObject | None
|
a native |
None
|
Methods:
| Name | Description |
|---|---|
get_id_token |
Get a Firebase ID token, to prove who the user is to your backend. |
get_id_token_result |
Get a Firebase ID token and its claims (including custom claims). |
reload |
Fetch the user's latest profile from the server (for example to see |
delete |
Delete the account and sign the user out. |
update_password |
Change the password. |
update_email |
Change the email address right away, without verifying it. |
update_profile |
Change the display name and/or photo URL. |
update_phone_number |
Change the phone number, with a credential from |
send_email_verification |
Email the user a link to verify their address. |
send_email_verification_before_updating_email |
Email a link to |
link_with_credential |
Add a sign-in method to this account (for example turn an anonymous |
link_with_provider |
Link an OAuth provider through its web sign-in flow. |
unlink |
Remove a sign-in method from this account. |
reauthenticate_with_credential |
Sign in again with a fresh credential, before sensitive actions |
reauthenticate_with_provider |
Re-authenticate through an OAuth provider's web sign-in flow. |
Attributes:
| Name | Type | Description |
|---|---|---|
auth |
ObjCObject
|
The native |
user |
ObjCObject | None
|
The native |
is_signed_in |
bool
|
True if this |
uid |
str | None
|
The user's Firebase ID: unique and stable. Use it as your database key. |
email |
str | None
|
The email address, or |
display_name |
str | None
|
The display name, or |
phone_number |
str | None
|
The phone number (E.164), or |
photo_url |
str | None
|
The profile photo URL, or |
provider_id |
str | None
|
Always |
is_anonymous |
bool
|
True for an anonymous user ( |
is_email_verified |
bool
|
True once the user has verified their email address. |
provider_data |
list[UserInfo]
|
The user's profile at each linked provider (email, Google, ...). |
metadata |
UserMetadata | None
|
When the account was created and last signed in, or |
multi_factor |
MultiFactor
|
The user's second factors: list, enroll, unenroll. |
tenant_id |
str | None
|
The tenant the user belongs to (multi-tenancy), or |
refresh_token |
str | None
|
The refresh token. Keep it secret; you rarely need it. |
user
instance-attribute
¶
user: ObjCObject | None = (
user if user is not None else self.auth.currentUser
)
The native FIRUser, or None.
uid
property
¶
The user's Firebase ID: unique and stable. Use it as your database key.
is_email_verified
property
¶
True once the user has verified their email address.
provider_data
property
¶
provider_data: list[UserInfo]
The user's profile at each linked provider (email, Google, ...).
metadata
property
¶
metadata: UserMetadata | None
When the account was created and last signed in, or None.
multi_factor
property
¶
multi_factor: MultiFactor
The user's second factors: list, enroll, unenroll.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
refresh_token
property
¶
The refresh token. Keep it secret; you rarely need it.
get_id_token
¶
get_id_token(
callback: Callable[
[str | None, AuthError | None], None
],
force_refresh: bool = False,
) -> None
Get a Firebase ID token, to prove who the user is to your backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[str | None, AuthError | None], None]
|
gets |
required |
force_refresh
|
bool
|
get a new token from the server even if the cached one is still valid (for example after custom claims changed). |
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
get_id_token_result
¶
get_id_token_result(
callback: Callable[
[IDTokenResult | None, AuthError | None], None
],
force_refresh: bool = False,
) -> None
Get a Firebase ID token and its claims (including custom claims).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[IDTokenResult | None, AuthError | None], None]
|
gets |
required |
force_refresh
|
bool
|
get a new token from the server, for example after your backend changed the user's custom claims. |
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
reload
¶
Fetch the user's latest profile from the server (for example to see
is_email_verified change after they clicked the link).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
ErrorCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
delete
¶
Delete the account and sign the user out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
ErrorCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
update_password
¶
Change the password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
password
|
str
|
the new password. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
update_email
¶
Change the email address right away, without verifying it.
Firebase rejects this when email enumeration protection is on (the
default for new projects); use send_email_verification_before_updating_email.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the new email address. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
update_profile
¶
update_profile(
callback: ErrorCallback | None = None,
*,
display_name: str | None | _Unset = UNSET,
photo_url: str | None | _Unset = UNSET,
) -> None
Change the display name and/or photo URL.
::
user.update_profile(on_done, display_name="Ada Lovelace")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
ErrorCallback | None
|
gets |
None
|
display_name
|
str | None | _Unset
|
the new display name; |
UNSET
|
photo_url
|
str | None | _Unset
|
the new photo URL; |
UNSET
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
update_phone_number
¶
update_phone_number(
credential: AuthCredential,
callback: ErrorCallback | None = None,
) -> None
Change the phone number, with a credential from PhoneAuthProvider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
AuthCredential
|
a phone credential for the new number. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
send_email_verification
¶
send_email_verification(
callback: ErrorCallback | None = None,
action_code_settings: ActionCodeSettings | None = None,
) -> None
Email the user a link to verify their address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
ErrorCallback | None
|
gets |
None
|
action_code_settings
|
ActionCodeSettings | None
|
where the link leads, or |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
send_email_verification_before_updating_email
¶
send_email_verification_before_updating_email(
email: str,
callback: ErrorCallback | None = None,
action_code_settings: ActionCodeSettings | None = None,
) -> None
Email a link to email; the address changes once the user opens it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
the new email address. |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
action_code_settings
|
ActionCodeSettings | None
|
where the link leads, or |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
link_with_credential
¶
link_with_credential(
credential: AuthCredential,
callback: DataResultCallback | None = None,
) -> None
Add a sign-in method to this account (for example turn an anonymous user into an email/password one).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
AuthCredential
|
the credential to link. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
link_with_provider
¶
link_with_provider(
provider: OAuthProvider,
callback: DataResultCallback | None = None,
) -> None
Link an OAuth provider through its web sign-in flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
OAuthProvider
|
the provider, for example |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
unlink
¶
unlink(
provider_id: str,
callback: Callable[
[User | None, AuthError | None], None
]
| None = None,
) -> None
Remove a sign-in method from this account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_id
|
str
|
the provider to unlink, for example |
required |
callback
|
Callable[[User | None, AuthError | None], None] | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
reauthenticate_with_credential
¶
reauthenticate_with_credential(
credential: AuthCredential,
callback: DataResultCallback | None = None,
) -> None
Sign in again with a fresh credential, before sensitive actions
(delete, update_password) that need a recent sign-in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
AuthCredential
|
a credential for this same user. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
reauthenticate_with_provider
¶
reauthenticate_with_provider(
provider: OAuthProvider,
callback: DataResultCallback | None = None,
) -> None
Re-authenticate through an OAuth provider's web sign-in flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
OAuthProvider
|
the provider the user signed in with. |
required |
callback
|
DataResultCallback | None
|
gets |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
no user is signed in. |
pyios_firebase.auth.google¶
Google Sign-In, then Firebase Auth.
from pyios_firebase.auth.google import start_google_sign_in
def on_signed_in(result, error):
if error is not None:
if not error.cancelled: # cancelled: the user closed the sheet
print("Sign-in failed:", error.description)
return
print("Signed in:", result.user.uid)
start_google_sign_in(on_signed_in)
Needs the GoogleSignIn framework, and the reversed client ID URL scheme
(com.googleusercontent.apps.YOUR-CLIENT-ID) in CFBundleURLTypes.
Functions:
| Name | Description |
|---|---|
get_google_credential |
Show the Google sign-in sheet and give back a Firebase credential, |
start_google_sign_in |
Show the Google sign-in sheet, then sign in to Firebase. |
sign_out_of_google |
Sign out of Google Sign-In, so the next sign-in shows the account picker. |
on_gid_signin_handle_url |
Give a URL the app was opened with to Google Sign-In. |
on_gid_signin_handle_url_kivy |
Kivy handler: |
Attributes:
| Name | Type | Description |
|---|---|---|
GOOGLE_SIGN_IN_CANCELED |
Final
|
|
GOOGLE_SIGN_IN_DOMAIN |
Final
|
The error domain of Google Sign-In errors. |
GOOGLE_SIGN_IN_CANCELED
module-attribute
¶
GIDSignInErrorCode.canceled: the user closed the Google sheet.
GOOGLE_SIGN_IN_DOMAIN
module-attribute
¶
The error domain of Google Sign-In errors.
get_google_credential
¶
Show the Google sign-in sheet and give back a Firebase credential, without signing in to Firebase (for example to link Google to the current user, or to re-authenticate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
CredentialCallback
|
gets |
required |
start_google_sign_in
¶
start_google_sign_in(
callback: DataResultCallback, auth: Auth | None = None
) -> None
Show the Google sign-in sheet, then sign in to Firebase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
DataResultCallback
|
gets |
required |
auth
|
Auth | None
|
the |
None
|
sign_out_of_google
¶
Sign out of Google Sign-In, so the next sign-in shows the account picker.
Call it with Auth.sign_out(), which signs out of Firebase only.
on_gid_signin_handle_url
¶
Give a URL the app was opened with to Google Sign-In.
Call it from your app's "open URL" handler. Newer Google Sign-In versions finish without it, so it is a safe backup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_string
|
str
|
the URL. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if Google Sign-In handled the URL; False if it is not a sign-in URL. |
on_gid_signin_handle_url_kivy
¶
Kivy handler: Window.bind(on_drop_file=on_gid_signin_handle_url_kivy).
Kivy (SDL) passes URLs the app was opened with as "dropped files"; this
forwards them to on_gid_signin_handle_url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | bytes
|
the URL, as Kivy passes it ( |
required |
pyios_firebase.auth.apple¶
Sign in with Apple, then Firebase Auth.
from pyios_firebase.auth.apple import start_apple_sign_in
def on_signed_in(result, error):
if error is not None:
if not error.cancelled:
print(error.message or error.description)
return
print("Signed in:", result.user.uid, result.first_name)
start_apple_sign_in(on_signed_in)
Apple shares the name (and a real or relay email) only the FIRST time a user
signs in to the app; later sign-ins give "" for those. The name is kept on
the device until a Firebase sign-in carries it.
Needs the com.apple.developer.applesignin entitlement and the Apple
provider enabled in the Firebase console (Authentication, Sign-in method).
Classes:
| Name | Description |
|---|---|
AppleCredential |
What Sign in with Apple gave, ready for Firebase. |
AppleSignInResult |
A Firebase sign-in with Apple: an |
Functions:
| Name | Description |
|---|---|
get_apple_credential |
Show the Sign in with Apple sheet and give back a Firebase credential, |
start_apple_sign_in |
Show the Sign in with Apple sheet, then sign in to Firebase. |
Attributes:
| Name | Type | Description |
|---|---|---|
AUTHORIZATION_ERROR_DOMAIN |
Final
|
The error domain of Apple's sign-in errors. |
AUTHORIZATION_ERROR_UNKNOWN |
Final
|
Set-up problems, or no Apple Account on the device (also: the user closed |
AUTHORIZATION_ERROR_CANCELED |
Final
|
|
AUTHORIZATION_ERROR_DOMAIN
module-attribute
¶
AUTHORIZATION_ERROR_DOMAIN: Final = _string_constant(
"ASAuthorizationErrorDomain",
"com.apple.AuthenticationServices.AuthorizationError",
)
The error domain of Apple's sign-in errors.
AUTHORIZATION_ERROR_UNKNOWN
module-attribute
¶
Set-up problems, or no Apple Account on the device (also: the user closed iOS's "sign in to your Apple Account" alert).
AUTHORIZATION_ERROR_CANCELED
module-attribute
¶
ASAuthorizationErrorCanceled: the user closed the Apple sheet.
AppleCredential
dataclass
¶
AppleCredential(
credential: OAuthCredential,
apple_user: str,
first_name: str,
last_name: str,
email: str,
authorization_code: str,
)
What Sign in with Apple gave, ready for Firebase.
Attributes:
| Name | Type | Description |
|---|---|---|
credential |
OAuthCredential
|
The Firebase credential (provider |
apple_user |
str
|
Apple's stable ID for the user in this app. |
first_name |
str
|
The given name: only on the first sign-in to the app, else |
last_name |
str
|
The family name: same rules as |
email |
str
|
The email (real or private relay): only on the first sign-in, else |
authorization_code |
str
|
A short-lived code: pass it to |
credential
instance-attribute
¶
credential: OAuthCredential
The Firebase credential (provider "apple.com").
first_name
instance-attribute
¶
The given name: only on the first sign-in to the app, else ""
(or the name kept from an earlier, failed attempt).
email
instance-attribute
¶
The email (real or private relay): only on the first sign-in, else "".
authorization_code
instance-attribute
¶
A short-lived code: pass it to Auth.revoke_token before deleting the
account (App Store rule).
AppleSignInResult
¶
AppleSignInResult(
native: ObjCObject, apple: AppleCredential
)
Bases: AuthDataResult
A Firebase sign-in with Apple: an AuthDataResult plus what Apple shared.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
apple
|
AppleCredential
|
what Apple gave for this sign-in. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
apple |
What Apple gave (names, email, authorization code). |
|
first_name |
str
|
The given name Apple shared (first sign-in only), else |
last_name |
str
|
The family name Apple shared (first sign-in only), else |
PyAppleSignInDelegate
¶
Bases: NSObject
The ASAuthorizationController delegate and presentation context.
Rubicon reads these methods' annotations to build their Objective-C
signatures: parameters must be annotated with ctypes types (objc_id),
not Python types.
Methods:
| Name | Description |
|---|---|
presentationAnchorForAuthorizationController_ |
The window the Apple sheet is shown over: the key window. |
authorizationController_didCompleteWithAuthorization_ |
Apple signed the user in: turn the identity token into a credential. |
authorizationController_didCompleteWithError_ |
Apple sign-in failed or was cancelled: report it. |
presentationAnchorForAuthorizationController_
¶
The window the Apple sheet is shown over: the key window.
authorizationController_didCompleteWithAuthorization_
¶
authorizationController_didCompleteWithAuthorization_(
controller: objc_id, authorization: objc_id
) -> None
Apple signed the user in: turn the identity token into a credential.
authorizationController_didCompleteWithError_
¶
Apple sign-in failed or was cancelled: report it.
get_apple_credential
¶
Show the Sign in with Apple sheet and give back a Firebase credential, without signing in to Firebase (for example to link Apple to the current user, or to re-authenticate before deleting the account).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
AppleCredentialCallback
|
gets |
required |
start_apple_sign_in
¶
start_apple_sign_in(
callback: AppleSignInCallback, auth: Auth | None = None
) -> None
Show the Sign in with Apple sheet, then sign in to Firebase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
AppleSignInCallback
|
gets |
required |
auth
|
Auth | None
|
the |
None
|
pyios_firebase.auth.facebook¶
Facebook Login, then Firebase Auth.
from pyios_firebase.auth import facebook
facebook.initialize_facebook() # once, at app start
def on_signed_in(result, error):
if error is not None:
if not error.cancelled:
print("Sign-in failed:", error.description)
return
print("Signed in:", result.user.uid)
facebook.start_facebook_sign_in(on_signed_in)
Both of Facebook's login modes work:
- classic login gives an access token (also usable with the Graph API);
- Limited Login (
limited=True, and what iOS falls back to when the user has not allowed tracking) gives an OpenID Connect token, checked with a nonce.
Needs the FacebookLogin framework (Swift package
https://github.com/facebook/facebook-ios-sdk, product FacebookLogin),
the Facebook provider enabled in the Firebase console, and in Info.plist:
FacebookAppID, FacebookClientToken, FacebookDisplayName, the URL
scheme fb<APP_ID>, and LSApplicationQueriesSchemes with fbapi and
fb-messenger-share-api.
Functions:
| Name | Description |
|---|---|
initialize_facebook |
Start the Facebook SDK. Call it once, at app start (Facebook's |
on_facebook_handle_url |
Give a URL the app was opened with to the Facebook SDK (the login |
on_facebook_handle_url_kivy |
Kivy handler: |
get_facebook_credential |
Show Facebook Login and give back a Firebase credential, without signing |
start_facebook_sign_in |
Show Facebook Login, then sign in to Firebase. |
sign_out_of_facebook |
Log out of Facebook Login (the next login asks again). |
Attributes:
| Name | Type | Description |
|---|---|---|
FACEBOOK_LOGIN_TRACKING_ENABLED |
Final
|
|
FACEBOOK_LOGIN_TRACKING_LIMITED |
Final
|
|
FACEBOOK_LOGIN_TRACKING_ENABLED
module-attribute
¶
FBSDKLoginTrackingEnabled: classic login (an access token).
FACEBOOK_LOGIN_TRACKING_LIMITED
module-attribute
¶
FBSDKLoginTrackingLimited: Limited Login (an OpenID Connect token).
initialize_facebook
¶
Start the Facebook SDK. Call it once, at app start (Facebook's
application(_:didFinishLaunchingWithOptions:) step).
Returns:
| Type | Description |
|---|---|
bool
|
What the Facebook SDK returns (True when it started). |
on_facebook_handle_url
¶
Give a URL the app was opened with to the Facebook SDK (the login redirect back from the Facebook app or Safari).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_string
|
str
|
the URL. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the Facebook SDK handled it. |
on_facebook_handle_url_kivy
¶
Kivy handler: Window.bind(on_drop_file=on_facebook_handle_url_kivy).
Kivy (SDL) passes URLs the app was opened with as "dropped files"; this
forwards them to on_facebook_handle_url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | bytes
|
the URL, as Kivy passes it ( |
required |
get_facebook_credential
¶
get_facebook_credential(
callback: CredentialCallback,
permissions: Sequence[str] = DEFAULT_PERMISSIONS,
limited: bool = False,
) -> None
Show Facebook Login and give back a Firebase credential, without signing in to Firebase (for example to link Facebook to the current user).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
CredentialCallback
|
gets |
required |
permissions
|
Sequence[str]
|
the Facebook permissions to ask for. |
DEFAULT_PERMISSIONS
|
limited
|
bool
|
True for Limited Login (no tracking). Facebook may also use Limited Login on its own when the user has not allowed tracking; both give a working credential. |
False
|
start_facebook_sign_in
¶
start_facebook_sign_in(
callback: DataResultCallback,
permissions: Sequence[str] = DEFAULT_PERMISSIONS,
limited: bool = False,
auth: Auth | None = None,
) -> None
Show Facebook Login, then sign in to Firebase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
DataResultCallback
|
gets |
required |
permissions
|
Sequence[str]
|
the Facebook permissions to ask for. |
DEFAULT_PERMISSIONS
|
limited
|
bool
|
True for Limited Login (see |
False
|
auth
|
Auth | None
|
the |
None
|
sign_out_of_facebook
¶
Log out of Facebook Login (the next login asks again).
Call it with Auth.sign_out(), which signs out of Firebase only.
pyios_firebase.auth.multi_factor¶
Multi-factor authentication: SMS and TOTP (authenticator app) second factors.
Enroll a second factor for the signed-in user::
mfa = auth.current_user.multi_factor
mfa.get_session(on_session) # 1. a session
PhoneAuthProvider().verify_phone_number( # 2. SMS for enrollment
"+15555550100", on_code_sent, multi_factor_session=session)
assertion = PhoneMultiFactorGenerator.assertion(phone.credential(verification_id, code))
mfa.enroll(assertion, "My phone", on_enrolled) # 3. enroll
Sign in when a second factor is required::
def on_signed_in(result, error):
if error is not None and error.code == AuthErrorCode.SECOND_FACTOR_REQUIRED:
resolver = error.resolver # hints: the user's factors
... # verify one, then:
resolver.resolve_sign_in(assertion, on_signed_in)
Multi-factor needs Identity Platform (Firebase Authentication with Identity Platform) and the factor enabled in the console. Enrolling needs a verified email address.
Classes:
| Name | Description |
|---|---|
MultiFactorSession |
Proves the first factor was just completed (or that the user is signed |
MultiFactorInfo |
One enrolled second factor. |
PhoneMultiFactorInfo |
An enrolled SMS second factor. |
MultiFactorAssertion |
Proof of a second factor, for |
PhoneMultiFactorGenerator |
Make SMS second-factor assertions. |
TOTPSecret |
A new TOTP secret, to show to the user while they set up their |
TOTPMultiFactorGenerator |
Make TOTP (authenticator app) secrets and assertions. |
MultiFactor |
A user's second factors. Get it with |
MultiFactorResolver |
Finishes a sign-in that needs a second factor. Get it from |
Attributes:
| Name | Type | Description |
|---|---|---|
PHONE_FACTOR_ID |
Final
|
The |
TOTP_FACTOR_ID |
Final
|
The |
PHONE_FACTOR_ID
module-attribute
¶
The factor_id of SMS second factors.
TOTP_FACTOR_ID
module-attribute
¶
The factor_id of TOTP (authenticator app) second factors.
MultiFactorSession
¶
MultiFactorSession(native: ObjCObject)
Proves the first factor was just completed (or that the user is signed
in, for enrollment). Pass it to SMS verification or generate_secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
MultiFactorInfo
¶
MultiFactorInfo(native: ObjCObject)
One enrolled second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
uid |
str
|
The factor's ID (its enrollment ID for TOTP sign-in). |
factor_id |
str
|
|
display_name |
str | None
|
The name given at enrollment, or |
enrollment_date |
datetime | None
|
When the factor was enrolled (UTC). |
PhoneMultiFactorInfo
¶
PhoneMultiFactorInfo(native: ObjCObject)
Bases: MultiFactorInfo
An enrolled SMS second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
phone_number |
str
|
The phone number, usually masked in sign-in hints ( |
phone_number
property
¶
The phone number, usually masked in sign-in hints (+*******0100).
MultiFactorAssertion
¶
MultiFactorAssertion(native: ObjCObject)
Proof of a second factor, for MultiFactor.enroll or
MultiFactorResolver.resolve_sign_in. Make it with
PhoneMultiFactorGenerator or TOTPMultiFactorGenerator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
factor_id |
str
|
|
PhoneMultiFactorGenerator
¶
Make SMS second-factor assertions.
Methods:
| Name | Description |
|---|---|
assertion |
An assertion from a phone credential. |
assertion
staticmethod
¶
assertion(
credential: AuthCredential,
) -> MultiFactorAssertion
An assertion from a phone credential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
AuthCredential
|
from |
required |
Returns:
| Type | Description |
|---|---|
MultiFactorAssertion
|
A |
TOTPSecret
¶
TOTPSecret(native: ObjCObject)
A new TOTP secret, to show to the user while they set up their authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Methods:
| Name | Description |
|---|---|
shared_secret_key |
The secret, to type into an authenticator app by hand. |
generate_qr_code_url |
An |
open_in_otp_app |
Open the URL in an installed authenticator app (if there is one). |
Attributes:
| Name | Type | Description |
|---|---|---|
native |
ObjCObject
|
The |
shared_secret_key
¶
The secret, to type into an authenticator app by hand.
generate_qr_code_url
¶
An otpauth:// URL, to show as a QR code for an authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_name
|
str
|
shown in the authenticator app, usually the email. |
required |
issuer
|
str
|
your app's name, shown in the authenticator app. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The URL. |
open_in_otp_app
¶
Open the URL in an installed authenticator app (if there is one).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qr_code_url
|
str
|
from |
required |
TOTPMultiFactorGenerator
¶
Make TOTP (authenticator app) secrets and assertions.
Methods:
| Name | Description |
|---|---|
generate_secret |
Make a new TOTP secret for enrollment. |
assertion_for_enrollment |
An assertion to enroll the authenticator app. |
assertion_for_sign_in |
An assertion to finish a sign-in with the authenticator app. |
generate_secret
staticmethod
¶
generate_secret(
session: MultiFactorSession,
callback: Callable[
[TOTPSecret | None, AuthError | None], None
],
) -> None
Make a new TOTP secret for enrollment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
MultiFactorSession
|
from |
required |
callback
|
Callable[[TOTPSecret | None, AuthError | None], None]
|
gets |
required |
assertion_for_enrollment
staticmethod
¶
assertion_for_enrollment(
secret: TOTPSecret, one_time_password: str
) -> MultiFactorAssertion
An assertion to enroll the authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret
|
TOTPSecret
|
from |
required |
one_time_password
|
str
|
the 6-digit code the app shows now. |
required |
Returns:
| Type | Description |
|---|---|
MultiFactorAssertion
|
A |
assertion_for_sign_in
staticmethod
¶
assertion_for_sign_in(
enrollment_id: str, one_time_password: str
) -> MultiFactorAssertion
An assertion to finish a sign-in with the authenticator app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enrollment_id
|
str
|
the |
required |
one_time_password
|
str
|
the 6-digit code the app shows now. |
required |
Returns:
| Type | Description |
|---|---|
MultiFactorAssertion
|
A |
MultiFactor
¶
MultiFactor(native: ObjCObject)
A user's second factors. Get it with User.multi_factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Methods:
| Name | Description |
|---|---|
get_session |
Start an enrollment: get a session for SMS verification or a TOTP secret. |
enroll |
Enroll a second factor. |
unenroll |
Remove a second factor. |
Attributes:
| Name | Type | Description |
|---|---|---|
enrolled_factors |
list[MultiFactorInfo]
|
The enrolled second factors ( |
enrolled_factors
property
¶
enrolled_factors: list[MultiFactorInfo]
The enrolled second factors (PhoneMultiFactorInfo for SMS).
get_session
¶
get_session(
callback: Callable[
[MultiFactorSession | None, AuthError | None], None
],
) -> None
Start an enrollment: get a session for SMS verification or a TOTP secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[MultiFactorSession | None, AuthError | None], None]
|
gets |
required |
enroll
¶
enroll(
assertion: MultiFactorAssertion,
display_name: str | None = None,
callback: ErrorCallback | None = None,
) -> None
Enroll a second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assertion
|
MultiFactorAssertion
|
from |
required |
display_name
|
str | None
|
a name to show in sign-in hints, for example "Work phone". |
None
|
callback
|
ErrorCallback | None
|
gets |
None
|
unenroll
¶
unenroll(
factor: MultiFactorInfo | str,
callback: ErrorCallback | None = None,
) -> None
Remove a second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factor
|
MultiFactorInfo | str
|
the factor, or its |
required |
callback
|
ErrorCallback | None
|
gets |
None
|
MultiFactorResolver
¶
MultiFactorResolver(native: ObjCObject)
Finishes a sign-in that needs a second factor. Get it from
AuthError.resolver when error.code == AuthErrorCode.SECOND_FACTOR_REQUIRED.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
native
|
ObjCObject
|
the native |
required |
Methods:
| Name | Description |
|---|---|
resolve_sign_in |
Finish the sign-in with a second factor. |
Attributes:
| Name | Type | Description |
|---|---|---|
hints |
list[MultiFactorInfo]
|
The user's enrolled factors: let them choose one. |
session |
MultiFactorSession
|
The session proving the first factor: pass it to SMS verification. |
session
property
¶
session: MultiFactorSession
The session proving the first factor: pass it to SMS verification.
resolve_sign_in
¶
resolve_sign_in(
assertion: MultiFactorAssertion,
callback: Callable[
[AuthDataResult | None, AuthError | None], None
]
| None = None,
) -> None
Finish the sign-in with a second factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assertion
|
MultiFactorAssertion
|
from |
required |
callback
|
Callable[[AuthDataResult | None, AuthError | None], None] | None
|
gets |
None
|