Developer-facing classes included in the firebase_auth_lite
folder.
The Firebase Auth service interface.
Do not call this constructor directly. Instead, use firebase.auth()
.
See Firebase Authentication for a full guide on how to use the Firebase Auth service.
Signal | Passes | Typical usage |
---|---|---|
"on_auth_state_changed" |
FirebaseUser |
Triggered on sign-in or sign-out. |
"on_id_token_changed" |
FirebaseUser |
Triggered on changes to the signed-in user's ID token, which includes sign-in, sign-out, and token refresh events. |
Property | Type (cast as) | Description |
---|---|---|
app |
Node (FirebaseApp ) |
The app associated with the FirebaseAuth service instance. |
current_user |
FirebaseUser |
The currently signed-in user (or null). |
🔻 = asynchronous. These should be called from inside a yield()
in a linear procedure.
Method | Returns (cast as) | Typical usage |
---|---|---|
🔻create_user_with_email_and_password(email, password) |
Object (FirebaseUser or FirebaseError ) |
Creates a new user account associated with the specified email address and password. |
🔻send_password_reset_email(email) |
Object (OK or FirebaseError ) |
Sends a password reset email to the given email address. The default password reset process is completed by firebaseapp.com's own service. |
🔻sign_in_with_email_and_password(email, password) |
Object (FirebaseUser or FirebaseError ) |
Signs in using an email and password. |
🔻sign_in_anonymously() |
Object (FirebaseUser or FirebaseError ) |
Signs in as an anonymous user. If there is already an anonymous user signed in, that user will be returned; otherwise, a new anonymous user identity will be created and returned. |
sign_out() |
void | Signs out the current user. |
- https://firebase.google.com/docs/reference/js/firebase.auth
- https://firebase.google.com/docs/reference/js/firebase.auth.Auth
Differences from the JavaScript SDK:
onAuthStateChanged()
andonIdTokenChanged()
replaced by signals,"on_auth_state_changed"
and"on_id_token_changed"
. The JS methods also include optional callbacks for auth errors but signals have not yet been provided to match (as the use cases are not clear to me over other error handling).- This lite version does not have an equivalent object to
UserCredential
yet. Thus, the methods that return aUserCredential
in JS return aFirebaseUser
object here (equivalent toUserCredential.user
). - Cases changed from camelCase to snake_case, where appropriate. For example,
currentUser
renamed tocurrent_user
. - This lite version does not implement all features.
Note: There is no estimate as to when OAuth, phone, or email-link auth might arrive.
A Firebase user account.
Property | Type | Description |
---|---|---|
display_name |
String |
|
email |
String |
|
email_verified |
bool |
|
is_anonymous |
bool |
|
metadata |
UserMetadata Dictionary |
UserMetadata |
phone_number |
String |
|
photo_url |
String |
|
provider_data |
Array |
|
provider_id |
String |
|
refresh_token |
String |
|
uid |
String |
🔻 = asynchronous. These should be called from inside a yield()
in a linear procedure.
Method | Returns (cast as) | Typical usage |
---|---|---|
🔻delete() |
Object (OK or FirebaseError ) |
Deletes and signs out the user. |
🔻get_id_token(<force_refresh>) |
Object (JWT String or FirebaseError ) |
Returns a JSON Web Token (JWT) used to identify the user to a Firebase service. Returns the current token if it has not expired. Otherwise, this will refresh the token and return a new one. |
🔻get_id_token_result(<force_refresh>) |
Object (IdTokenResult Dictionary or FirebaseError ) |
Returns an IdTokenResult dictionary (fake class). |
🔻reload() |
Object (OK or FirebaseError ) |
Refreshes the current user, if signed in. |
🔻send_email_verification() |
Object (OK or FirebaseError ) |
Sends a verification email to a user. The default verfication process is completed by firebaseapp.com's own service. |
🔻verify_before_update_email(new_email) |
Object (OK or FirebaseError ) |
Sends a verification email to a new email address. The user's email will be updated to the new one after being verified. The default verfication process is completed by firebaseapp.com's own service. |
🔻update_email(new_email) |
Object (OK or FirebaseError ) |
Updates the user's email address. An email will be sent to the original email address (if it was set) that allows to revoke the email address change, in order to protect them from account hijacking. Important: this is a security sensitive operation that requires the user to have recently signed in. |
🔻update_password(new_password) |
Object (OK or FirebaseError ) |
Updates the user's password. Important: this is a security sensitive operation that requires the user to have recently signed in. |
🔻update_profile(profile) |
Object (OK or FirebaseError ) |
Updates a user's profile data. |
profile: { display_name: String | null; photo_url: String | null }
- The profile's display_name and photo_url to update.
- display_name: String | null (optional). Set to
null
to delete current value. - photo_url: String | null (optional). Set to
null
to delete current value.
- display_name: String | null (optional). Set to
- Example:
{"display_name": "Super Dave", "photo_url": "http://placekitten.com/100/100"}
Differences from the JavaScript SDK:
- Cases changed from camelCase to snake_case, where appropriate. For example,
displayName
renamed todisplay_name
. - This lite version does not implement all features.
Interface representing ID token result obtained from FirebaseUser.get_id_token_result()
. It contains the ID token JWT string and other helper properties for getting different data associated with the token.
Property | Type | Description |
---|---|---|
auth_time_secs |
int |
The authentication time in OS epoch seconds. This is the time the user authenticated (signed in) and not the time the token was refreshed. |
expiration_interval_secs |
int |
Seconds this token lasts before it expires. Should always be 3600 in Firebase. |
expiration_time_secs |
int |
The ID token expiration time in OS epoch seconds. |
issued_at_time_secs |
int |
The ID token issued-at time in OS epoch seconds. |
token |
String |
The Firebase Auth ID token JWT string. |
Differences from the JavaScript SDK:
authTime
,issuedAtTime
, andexpirationTime
(which contain UTC strings) replaced by integer properties of similar name that are compatible with GDScript'sOS.get_system_time_secs()
etc.expiration_interval_secs
added just because the Firebase API always sends it (asexpires_in
). It is always 3600 but stored here in case it ever changes -- or you want a property to pull it from.
Interface representing a user's metadata.
Property | Type | Description |
---|---|---|
creation_time_secs |
int |
The user-account-creation time in OS epoch seconds. |
last_sign_in_time_secs |
int |
The user's last sign-in time in OS epoch seconds. |
Differences from the JavaScript SDK:
creationTime
andlastSignInTime
(which contain UTC strings) replaced by integer properties of similar name that are compatible with GDScript'sOS.get_system_time_secs()
etc.