Seems that there is a misunderstood about Cloud Functions for Firebase and Google Cloud Functions (the error message is because is used code for a Google Cloud Functions within a Cloud Function for Firebase), but anyway the answer of this question is that you can use adminRef instead ref in the code of the function that will write the data on Firebase database:
event.data.adminRef
instead event.data.ref
this will give you full read and write access instead of end-user access (please note that also you must take care to indicate within the rules deny to everybody).
Update: Seems that adminFef was replaced by ref due changes on Firebase, so follow the example to the respective replacement.