I'm trying to get the UID of the auth user who created the new document in the cloud trigger function for the onCreate event.
I couldn't find on the documentation website how to do this. However, it's documented in the source code of the 'firebase-functions' JavaScript library that this should be context.auth.uid as in the code below. However, the code below reports in the logs that context.auth is undefined when a document is added by an authenticated user.
import * as functions from "firebase-functions";
export const mytriggerFunction = functions.firestore
.document('someCollection/{documentId}')
.onCreate((snapshot, context) => {
console.log("Current auth:", context.auth);
return true
})