-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
In few words, is it possible to add an idToken when observing/listening a Collection throw snapshotChanges or valueChanges or any other method?
With this code in Angular I can observe changes in an entire collection (transfer is my Firestore collection):
public transfers: Observable<any[]>; constructor(db: AngularFirestore) { this.transfers = db.collection('/transfer').valueChanges();
and with this code I can observe a specific document:
public transfers: Observable<any[]>;
transferCollectionRef: AngularFirestoreCollection;
constructor(db: AngularFirestore) {
this.transferCollectionRef = db.collection<any>('transfer', ref => ref.where("id", "==", "1"));
this.transfers = this.transferCollectionRef.snapshotChanges().map(actions => {
return actions.map(action => {
const data = action.payload.doc.data();// as Todo;
const id = action.payload.doc.id;
return { id, ...data };
});
});
With this curl command I can use token also but obviously I curl isn't going to keep observing. I am just pasting curl scrupt to clarify what I mean by idToken generated from a Custom Token
curl --location --request POST 'https://firestore.googleapis.com/v1/projects/firetestjimis/databases/(default)/documents:runQuery'
--header 'Authorization: Bearer eyJh..... a valid idToken returned from
https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key ..... kUifgEtHT4ZXde1ehf_PIwNDx6_ZfJuQ'
--header 'Content-Type: application/json'
--data-raw '{
"structuredQuery": {
"where" : {
"fieldFilter" : {
"field": {"fieldPath": "id"},
"op":"EQUAL",
"value": {"stringValue": "1"}
}
},
"from": [{"collectionId": "transfer"}]
}
}'
So, my question is: how can I use same idToken while listening a Collection?