Ahikam
Ahikam

Reputation: 1

User get 401 when trying to fetch data from firebase realtime database

I am using REST API in my vuejs app to access firebase realtime database, I authenticate users using Google provider and get access token. Whe I try fetching data using access_token https://rtdb-url/uid/products.json?access_token=[access token] user get 401 error. But if the user was added to "Users and permissions" in project settings it works.

Rule appplied to RTDB

{
  "rules": {
    "$uid": {
      "products": {
        ".write": "auth != null && $uid === auth.uid",
        ".read": "auth != null && $uid === auth.uid"
      }
}

Upvotes: 0

Views: 179

Answers (1)

Ahikam
Ahikam

Reputation: 1

Apparently, I just needed to use the access token I got and send it to the following endpoint in the POST body:

https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=

As described in the documentation.

Upvotes: 0

Related Questions