lifelonglearner
lifelonglearner

Reputation: 27

How to create auth.uid for custom authentication firebase

I am new to firebase and am creating messaging app and using private otp service for registering phone number.i am using both real-time database and firestore so I need to protect database in security rules.it seems like using auth.uid is the only way to use in security rules.

I am saving chat thread in real-time database and saving user profiles in firestore.

How can I create auth.uid for security rules for my users phonenumber thats authenticated using private otp service.

Please help me how can I approach this.

Upvotes: 1

Views: 899

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599111

As Renaud commented, you'll want to:

  1. Sign in the user into your own custom backend.
  2. Use the information from this sign-in to generate a custom token with the Firebase Admin SDK
  3. Pass the custom token to the client.
  4. Sign the user in to Firebase on the client with the custom token.

At this point the information from the custom token is available in the security rules for Firestore and Realtime Database.

Upvotes: 0

Related Questions