DEV Community

Cover image for Create useful automations with plain Javascript 🧑‍💻

Create useful automations with plain Javascript 🧑‍💻

Anthony Lagrede on December 01, 2022

Are you more automatic or manual? Hi all 👋, Continuing my contribution to the developer community as app maker, today I propose to discu...
Collapse
 
mrgoonie profile image
Goon Nguyen

Brilliant, Anthony! Very clever!

Collapse
 
alagrede profile image
Anthony Lagrede

Thank you 🙏

Collapse
 
weaves87 profile image
Andrew Weaver

Great write up! And Zcode looks pretty cool, looking forward to checking it out!

Collapse
 
alagrede profile image
Anthony Lagrede

Thank you Andrew 😊

Collapse
 
azizqamar7 profile image
azizqamar7

How to encrypt mail & password?

Collapse
 
alagrede profile image
Anthony Lagrede • Edited

Hi,
I don't know if I'm answering your question correctly but you can do something like declare a json file containing your credentials:
google.json

{
 "email":"XXX@gmail.com",
 "app_password":"XXX"
}
Enter fullscreen mode Exit fullscreen mode

Then use it:

const credentials = require("./google.json");
console.log(credentials.email)
Enter fullscreen mode Exit fullscreen mode

You can also export your variable like this:
export GOOGLE_MAIL="XXX@gmail.com"
Then in your node script:

console.log(process.env.GOOGLE_MAIL)
Enter fullscreen mode Exit fullscreen mode

I hope this will help you 😊

Collapse
 
azizqamar7 profile image
azizqamar7

I've seen in smtpjs.com where you can encrypt your data by providing host name, email address and password, & port number. It gives secure token, but still here it's json file that might be accessible, isn't it?

Thread Thread
 
alagrede profile image
Anthony Lagrede

As long as the code is running on your server with NodeJS, the JSON file is not accessible. My comment is just about how to avoid to commit your credentials in Github as @darthwalsh pointed out.

Thread Thread
 
azizqamar7 profile image
azizqamar7

Ohh nice

Collapse
 
nagacharankumarreddy profile image
Naga Charan Kumar Reddy

Can we send mail if two step verification is enabled for our mail?

Collapse
 
darthwalsh profile image
Carl Walsh

Google app passwords are meant to be used in automation, bypassing 2FA. Make sure not to upload them to GitHub!