at.
at.

Reputation: 52550

Invalid characters in Firebase Auth uid?

I want to combine multiple Firebase Auth uids in a single string. So I need to know which characters can't possibly be in a uid. That way I can use one of them as a delimiter.

I've looked throughout Firebase's documentation and can't seem to find the answer

Upvotes: 3

Views: 1537

Answers (2)

Jürgen Brandstetter
Jürgen Brandstetter

Reputation: 7344

According to the documentation any string between 1 and 128 characters is allowed.

Source: https://firebase.google.com/docs/auth/admin/manage-users (see: Table 1. Properties supported by the create user operation)

Take care: While the uid can be any string, the realtime database can't use any string. So if you want to use the uid to create a document you must obey those rules Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"

Upvotes: 3

Grimthorr
Grimthorr

Reputation: 6926

The default randomly-generated Firebase Authentication uids are 28-character alphanumeric strings with no special characters.


Further research brought me to an answer from Firebase User ID Allowed Characters which suggests a pattern of:

^[0-9a-zA-Z]{27}[0-9]$

This matches the uids I have across a couple of Firebase projects, so seems to be correct.

From my experience, the latest version of Firebase follows the ^[0-9a-zA-Z]{27}[0-9]$ pattern.

I don't know why there's always a digit at the end, but that seems to be consistent.

Upvotes: 0

Related Questions