Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Firebase generate the Uid?

My question is how does Firebase generate the Uid? Is it generated from the app installation on the cellphone or maybe it is based on the login provider via email, Facebook, Google or the other ones that Firebase provide?

like image 949
Andrey Avatar asked Aug 04 '16 07:08

Andrey


People also ask

Is Firebase uid unique?

Firebase users have a fixed set of basic properties—a unique ID, a primary email address, a name and a photo URL—stored in the project's user database, that can be updated by the user (iOS, Android, web).

Does Firebase uid change?

It's best to use the Firebase Authentication UID as a Cloud Firestore document ID in this case. You might be tempted to use an email address as a per-user document ID, but I don't recommend that at all, as email addresses can change over time. UIDs will never change.

How long is Firebase uid?

The uid to assign to the newly created user. Must be a string between 1 and 128 characters long, inclusive. If not provided, a random uid will be automatically generated.


2 Answers

UUID is autogenerated based on timestamp and some entropy. UUID's can be sorted based on creation time, this helps to maintain indexes in Firebase.

UUID is not some hash of for example the email address, or facebook id or other. By removing all meaning from the uid itself, it is not dependent on any underlying properties and those properties can freely changed.

If you want to use custom UID you need to be consistent. It is recommended to not tight together user id creation and login property of some sort because the property can change, and you will have inconsistent user id.

like image 42
Marcel Mandatory Avatar answered Oct 10 '22 04:10

Marcel Mandatory


The Firebase User ID (often called uid) is an opaque identifier for a user account. It has no connection to the underlying identity provider(s) for the account and should be treated as an opaque value.

As per IndieWeb

“Opaque” is a term often used to refer to data such as URIs or other identifiers. An identifier is opaque if it provides no information about the thing it identifies other than being a seemingly random string or number.

like image 131
Frank van Puffelen Avatar answered Oct 10 '22 05:10

Frank van Puffelen