简体   繁体   中英

Postman Google API request gives “401: Unauthorized”

I'm sending post request via postman

https://my_app_id.firebaseio.com/databases/locations/documents/123456/1598539394290.json?key=WEB_API_KEY

Json:

{"latitude":12.345678,"longitude":12.345678,"timestamp":1598539394290,"userId":"123456"}

And getting error 401 Unauthorized with Json " {"error": "Permission denied"} "

Permissions at Firestore:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

Earlier I sent there request via google java SDK and everyting was ok, but for now I need to redo this via using API.

Please, help to figure out what is wrong.

The security rules you're showing are for Firestore, but the URL you're using is writing to Realtime Database, which is a completely different database. Actually, it looks like you're combining elements of the Firestore with Realtime Database APIs in that URL, which is very confusing.

If you want to write to Firestore, you should be using only the Firestore REST API documentation . Ignore everything you see in the Realtime Database API documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM