0

Screenshot of Firebase Cloud Functions Console Log

enter image description here

I have an app published on the Google Play store, which I built while learning android/firebase. I was a total newbie.

I added cloud functions that performed tasks like sending welcome emails to new users. However, while deploying the cloud functions/app, I was asked my gmail e-mail & password on the command line. I submitted them. However, I have changed my gmail password now & Google does not allow me to use old passwords again. So, my app fails to execute those cloud functions now due to authentication errors. The error log screenshot is attached.

How can I specify my new credentials so as to make my published app work normal again?

I could not find anything relevant or an option on the Firebase console for this. What best practices should be followed so that I don't get stuck like this in the future & can freely change passwords for developer accounts & not affect my apps?

Edit:

Here's the text from the screenshot:

sendWelcomeEmail Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials q187-v6sm4997775iof.67 - gsmtp at SMTPConnection._formatError (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:591:19) at SMTPConnection._actionAUTHComplete (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:1320:34) at SMTPConnection._responseActions.push.str (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:356:26) at SMTPConnection._processResponse (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:747:20) at SMTPConnection._onData (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:543:14) at TLSSocket._socket.on.chunk (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:495:47) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at TLSSocket.Readable.push (_stream_readable.js:134:10)

Here the function for sending emails via nodemailer:

 // Sends a welcome email to the given user.
function sendWelcomeEmail(email, displayName) {
  const mailOptions = {
    from: `noreply@example.com`,
    to: email
  };

  mailOptions.subject = `Welcome to ${APP_NAME}!`;
  mailOptions.text = `Hey ${displayName || ''},\n\nWelcome to ${APP_NAME}!...........`;
  return mailTransport.sendMail(mailOptions).then(() => {
    console.log('New welcome email sent to:', email);
  });
}
  • It is usually better to put text messages in your answer as text rather than as a screenshot. That way it is easier for people to copy and paste the relevant parts to help you. – Nick Fortescue Jul 16 '18 at 08:27
  • Can you give details of the code in your cloud functions (for sending email)? – Nick Fortescue Jul 16 '18 at 08:29
  • Okay, I will keep that in mind next time. Didn't realise it. Thank you @NickFortescue ! I have added the required details in the edits – user10083174 Jul 17 '18 at 14:55

2 Answers2

0

I just looked at the nodemailer documentation.

It looks like you specify your username and password when you create the mailTransport object (which you don't show the code for). You probably copied and pasted the code from something like this StackOverflow question

const mailTransport = nodemailer.createTransport(
    `smtps://user@domain.com:password@smtp.gmail.com`);

If this is what you did, then that's where you need to change the password.

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37
  • No, I did not follow this. The folowing link is what resembles the steps I follow: https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users – user10083174 Jul 18 '18 at 13:30
  • I am trying to find a way to set my credentials on my Firebase/Google console or somewhere similar which does not affect my existing app on the play store, preferable. So that I do not have to roll out an update for my app exclusively for this bug. – user10083174 Jul 18 '18 at 13:33
0

You need to edit your environment variables for your Firebase project.

To configure it easily, you can have a look at Google Cloud Shell. Open a shell for your project here.

And then, follow this to get/set your environment variables.

EDIT:

In the Google Cloud Shell, the command

firebase functions:config:get --project <project_id_here>

outputs the current Environment configuration for your project as a JSON. You can use this to inspect your environment variables.

For your problem, you might need to use the command,

firebase functions:config:set gmail.password="your_password_here" --project <project_id_here>

to set your environment variable (i.e. gmail.password) to a new value. The --project is required since you are working in the Google Cloud Shell.

  • Links only answers are not great, since links have a tendency to disappear. A summary of the solution would be more appropriate for this site's objectives. – Nic3500 Jul 18 '18 at 15:21