
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
gmail-sender-oauth
Advanced tools
Send emails with Gmail API using an OAuth2 object
#install and save
npm install gmail-sender-oauth --save
Require the module.
var gmailSender = require('gmail-sender-oauth');
Load Google Api Project client secret. To get this file follow Step 1 .
gmailSender.setClientSecretsFile('./client_secret.json');
Send an email specifying all the headers (i.e 'from', 'to', 'subject', 'body').
var params = {
from: 'sender.oauth@gmail.com',
to: 'sender.oauth@gmail.com',
subject: 'Win an iPhone 7 today!!!',
body: 'This is a test'
};
gmailSender.send(accessToken, params, function (err, resp) {
if (err) {
return console.error('Something went wrong: ' + err);
}
else {
console.log('Message sent with id: ' + resp.id);
}
});
This assumes you already have an access token from Google Api. To get one, see test Generate Access Token and if you need to start from scratch, generate a Server Auth code first, see test Generate Server Auth code .
#Terminal output
~/personal/gmail-sender-oauth/test$ node generate_server_auth.js
Authorize this app by visiting this url: https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.compose&response_type=code&client_id=1081826302113-deknk5sgd6n2vutgv3l4ub4530qqc8kh.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
If you need a accessToken to be generated as well, run:
node generate_access_token <SERVER_AUTH_CODE>, with the code you received from the visited URL.
~/personal/gmail-sender-oauth/test$ node generate_access_token.js 4/AR34xAC0Z437ItI_27FmpDYmCeNMpMWNyZk0G6cV6EQ
token: {"access_token":"ya29.Gls0BCt9gHK7Bmn5mPQFff6JCaVyt8ZcRiUgLPQL4SmAFk-msJOTIaISi-UiPhRD7QHR2n_8dJXymn08helwDCcnHpGK14sqHXhsH3fgTlvaNz1dZbA7P6LJO4BH","refresh_token":"1/kVLTLeR7vb1e6tuT6XHWBqZ0nG-qwldfeO1uhwdwBok","token_type":"Bearer","expiry_date":1492885695675}
FAQs
Send emails with Gmail API using an OAuth2 object
The npm package gmail-sender-oauth receives a total of 1 weekly downloads. As such, gmail-sender-oauth popularity was classified as not popular.
We found that gmail-sender-oauth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.