When I write data to Firestore from a logged in Android Client, I am not able to get the auth information on the onWrite trigger.
When I print the context object which is supposed to store auth object with UID, I see that auth object doesn't exist.
According to this link, https://firebase.google.com/docs/functions/beta-v1-diff?authuser=0#new_properties_for_user_auth_information
I should get this information on any writes on Firestore.
Here is the example code I Used.
exports.testTrigger = functions.firestore
.document('col1/doc1/col2/{doc2}')
.onWrite((change, context) => {
console.log('context = ', context);
const auth = context.auth;
console.log('auth = ', auth);
});
Output in Cloud Function Logs:
context = { eventId: '3c2295a4-2823-4fba-b406-728d7d77f6de-0',
timestamp: '2018-05-06T17:11:12.771855Z',
eventType: 'google.firestore.document.write',
resource:
{ service: 'firestore.googleapis.com',
name: 'projects/xyz/databases/(default)/documents/col1/doc1/col2/gFRWgJg37DmB5wchWLBV' },
params: { request_id: 'gFRWgJg37DmB5wchWLBV' } }
auth = undefined