From the course: React: Cloud-Powered Apps with Firebase

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Cloud Functions: Authentication trigger

Cloud Functions: Authentication trigger

From the course: React: Cloud-Powered Apps with Firebase

Start my 1-month free trial

Cloud Functions: Authentication trigger

- [Instructor] Let's try our function now. Firebase Cloud Functions allows you to set environment variables which is important because you don't want to write credentials in your code. In your terminal, you can set environment variables using firebase functions:config:set. Now we'll set two environment variables, the email, which is thegrid.notifier@gmail.com, and also the password. Go ahead and click Enter. Let's change directories into the functions folder and npm install nodemailer. And now we can write our function. We will first require firebase-functions. This is a package that was installed when we initialized Cloud Functions in our project. Let's go ahead and require nodemailer as well. In here, we can grab the environment variables. We need the email in call functions.config, and we store it in gmail.email, and also the gmailPassword, which was stored in gmail.password. Here we can create the node mailer…

Contents