user6288393
user6288393

Reputation: 227

How to use auto-increment integer user ids for firebase tokens

Is it possible to change those random UIDs strings in firebase to an integer?

I am using firebase tokens to authenticate on my back-end. In my back-end I also have a table which stores additional user data required for my application. This table has a user id column which is an integer primary key and also an additional firebase_id field to know which firebase uid corresponds to this user. Each time there is an authenticated request on my backend, the firebase token is sent and my backend uses the uid field to look up firebase_id == uid to get the matching user in my backend or create if it does not exist. I would like to get rid of firebase_id and make uid be an integer so that instead of querying firebase_id I can query the integer primary key of the users table.

Is this possible? Or are there any alternatives?

I want to do this for performance reasons, if that matters.

Upvotes: 0

Views: 539

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599131

The UID of a user is determined by the authentication provider that creates that user. None of the built-in providers allow you to control the UID that is created, so you're out of luck there.

What you can do is create your own authentication provider and use that with Firebase. The UID is then under your control.

Upvotes: 2

Related Questions