zac
zac

Reputation: 4898

How to Authenticate with Firebase realtime database using UID or Email and Password for REST API using postman

I used this protection rules in the database like this

{
  "rules": {
    "users": {
      "$userId": {
        ".read": "$userId === auth.uid",
        ".write": "$userId === auth.uid"
      }
    }
    
  }
}

In postman I tried GET with url.json but I get permission denied I tried to search the documentations how to find and pass current UID but could not find

Also for authentication with email and password I select in the postman Authorization "Basic Auth" and I went to firebase Project settings then I add member then I add email and select role "Firebase Admin" but where I get this user entered password to save it in postman ?

Upvotes: 2

Views: 1647

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598740

If you want to access the user's data via the REST API, you'll have to make sure the calls are authenticated as shown in the documentation.

The options for this are to add a parameter to the request:

  • either pass the OAuth2 token of a collaborator on the project in an access_token parameter,
  • or pass the ID token of the correct Firebase Authentication user in an auth parameter.

There is no way to pass just the UID of the user, as that would not be secure - as anyone could pass any value for as their UID in that case.

Upvotes: 3

Related Questions