简体   繁体   中英

How to connect particle.io webhook to firestore database?

I'm using particle.io for an application and I have the webhook working fine to the Realtime database using the database secret.

I'm making some updates and I want to start using the firestore database but the database secret does not work, I keep getting 403 not authorized when I add the database secret to my call.

Is there a way I can use the particle.io with the firebase admin SDK? On my firestore rule I have the following, so only authorized account can access the data.

service cloud.firestore {
    match /databases/{database}/documents {
       match /{document=**} {
          allow read, write: if request.auth != null;
       }
    }
}

This is the URL I'm using to post from the webhook.

https://firestore.googleapis.com/v1beta1/projects/ {projectId}/databases/(default)/documents/{documentName}?key={databasescret}

I go the URL from the API Explorer on firebase, but they use OAUTH and it was working fine with OAUTH, it just that I do not OAUTH option from the particle.io webhook.

Unfortunately Particle webhooks can't authenticate using OAuth (by default only HTTP Basic Auth is supported). There's a deprecated feature of Database Secrets ( Rick Kaseguma wrote a great tutorial about it.) but they will be retired at some point.

Seems like a replacement of secrets would be Firebase ID token for which you need to create an user and retrieve the ID token for this user.

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