Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
juttle-gmail-adapter
Advanced tools
Gmail adapter for the Juttle data flow language.
This uses the nodejs API for google to read and write gmail messages. It also uses Batchelor to perform batched email fetches, something that the main google API does not currently support.
read gmail -from :5 days ago: -raw "to:me"
| reduce count() by from
| sort count -desc
| view table -title "Who sends me the most mail?";
read gmail -from :5 days ago: -to :1 day ago: -raw "to:me"
| batch -every :1h:
| reduce count()
| view timechart -title "When during the day do I get mail?"
read gmail -from :5 days ago: -to :1 day ago: -raw "to:me"
| batch -every :1h:
| reduce count()
| write gmail -subject "When during the day do I get mail?"
Like Juttle itself, the adapter is installed as a npm package. Both Juttle and the adapter need to be installed side-by-side:
$ npm install juttle
$ npm install juttle-gmail-adapter
Configuration involves these steps:
.juttle/config.js
To create application credentials, follow the
nodejs quickstart instructions. This
will result in a file on disk titled client_secret.json
with this structure:
{
"installed": {
"client_id": "--your-client-id--",
"project_id": "--your-project-id",
"auth_uri": "https:\/\/accounts.google.com\/o\/oauth2\/auth",
"token_uri": "https:\/\/accounts.google.com\/o\/oauth2\/token",
"auth_provider_x509_cert_url": "https:\/\/www.googleapis.com\/oauth2\/v1\/certs",
"client_secret": "--your-client-secret-id--",
"redirect_uris": [
"urn:ietf:wg:oauth:2.0:oob",
"http:\/\/localhost"
]
}
}
You'll use this file in the next step.
You need to create an oauth2 token that allows this program to read your email on your behalf.
To do this, run node create_oauth_token.js
from the juttle-gmail-adapter directory.
This will provide a json config block to add to your .juttle/config.js
file.
This will also use the gmail nodejs api to read the list of labels assocated with the authenticated user, to verify that the token was created successfully.
.juttle/config.js
create_oauth_token.js
printed a configuration block like this:
{
"adapters": {
"gmail": {
"client-credentials": {
"installed": {
"client_id": "--your-client-id--",
"project_id": "--your-project-id",
"auth_uri": "https:\/\/accounts.google.com\/o\/oauth2\/auth",
"token_uri": "https:\/\/accounts.google.com\/o\/oauth2\/token",
"auth_provider_x509_cert_url": "https:\/\/www.googleapis.com\/oauth2\/v1\/certs",
"client_secret": "--your-client-secret-id--",
"redirect_uris": [
"urn:ietf:wg:oauth:2.0:oob",
"http:\/\/localhost"
]
}
},
"oauth2-token": {
"access_token": "---your-access-token---",
"token_type": "Bearer",
"refresh_token": "---your-refresh-token---",
"expiry_date": DDDDDDDDDDDDD
}
}
}
}
Add this configuration to your .juttle/config.js
file. If you
have an existing "adapters" section, for example:
{
"adapters": {
"twitter": {...}
}
}
Add the gmail section as a peer item below "adapters":
{
"adapters": {
"twitter": {...},
"gmail": {...}
}
}
Name | Type | Required | Description |
---|---|---|---|
raw | string | no | Use the following advanced search filter to select messages. |
from | moment | no | select messages after this time (inclusive) |
to | moment | no | select messages before this time (exclusive) |
Name | Type | Required | Description |
---|---|---|---|
to | string | no | the to: header of the message. If not specified, defaults to the email address of the authenticated user. |
subject | string | no | the subject of the message. Default is 'Juttle Program Output'. If output is split, " (part )" is appended to subject. |
limit | number | no | split output into batches of points. By default all points are buffered in memory until the program has completed. |
jsonOnly | boolean | no | if true, only include a raw JSON mime part in the email. The default (false) is to attach a plain/text as well as application/json part. |
If you want to write your own adapter, look at the detailed notes on how the Gmail adapter interacts with the Juttle runtime/compiler to fetch messages and pass them as points to the juttle program.
Want to contribute? Awesome! Don’t hesitate to file an issue or open a pull request.
0.4.2
Released 2016-01-21
FAQs
Juttle adapter for Gmail
The npm package juttle-gmail-adapter receives a total of 12 weekly downloads. As such, juttle-gmail-adapter popularity was classified as not popular.
We found that juttle-gmail-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.