Socket
Socket
Sign inDemoInstall

node-gmail-api

Package Overview
Dependencies
60
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 0.6.1

5

index.js

@@ -68,3 +68,4 @@ var request = require('request')

qs: {
q: q
q: q,
maxResults: i < 100 ? i : 100
},

@@ -100,4 +101,2 @@ headers: {

messages.length = i < 100 ? i : 100
var r = request({

@@ -104,0 +103,0 @@ method: 'POST',

2

package.json
{
"name": "node-gmail-api",
"version": "0.6.0",
"version": "0.6.1",
"description": "Interacts with the gmail api, fetching emails",

@@ -5,0 +5,0 @@ "main": "index.js",

node-gmail-api
==============
Node module to interact with the gmail api
Node module to interact with the gmail api.
Why not the [google official library](https://github.com/google/google-api-nodejs-client)? Well it does too much and doesn't implement batching.
Which means fetching a bunch of email is insanely painful. This module exposes a function which will query the api searching for messages and hit the google
batch api to fetch all the messages that are returned.
Which means fetching a bunch of email is insanely painful. This module exposes a function which will query the api searching for messages and hit the google batch api to fetch all the messages that are returned.
To use this module, you'll need an oauth access token key. See more details here: https://developers.google.com/gmail/api/overview#auth_and_the_gmail_api
### Authenticating users
We use [node-passport](https://github.com/jaredhanson/passport-google) to get an access key for a user, then use this module to make requests on behalf of the authenticated user.
To use this module, you'll need an oauth access token key. See more details here: https://developers.google.com/gmail/api/overview#auth_and_the_gmail_api.
You may use [passport-google-oauth](https://github.com/jaredhanson/passport-google-oauth) to get an access key for a user, then use this module to make requests on behalf of the authenticated user.
Example authentication call (cf. [passport-google-oauth](https://github.com/jaredhanson/passport-google-oauth) for more complete usage examples):
````javascript
passport.use(new GoogleStrategy({
clientID: config.googleApp.clientId
, clientSecret: config.googleApp.clientSecret
, userProfileURL: 'https://www.googleapis.com/oauth2/v3/userinfo'
, callbackURL: config.baseurl + '/oauth2callback'
}
, function(accessToken, refreshToken, profile, done) {
// do your thing here
}
))
````
Example
=======
```
// Fetch latest 10 emails and show the snippet
### Fetch latest 10 emails and show the snippet
````javascript
// assuming access token has already been retrieved inside variable `accessToken`
var Gmail = require('node-gmail-api')
, gmail = new Gmail(<KEY>)
, gmail = new Gmail(accessToken)
, s = gmail.messages('label:inbox', {max: 10})

@@ -27,11 +45,12 @@

})
```
````
### Optionally request the fields you want (for performance)
```
// Optionally request the fields you want (for performance)
// https://developers.google.com/gmail/api/guides/performance
cf. [gmail API performance guide](https://developers.google.com/gmail/api/guides/performance).
````javascript
var Gmail = require('node-gmail-api')
, gmail = new Gmail(<KEY>)
, gmail = new Gmail(accessToken)
, s = gmail.messages('label:inbox', { fields: ['id', 'internalDate', 'labelIds', 'payload']})

@@ -42,10 +61,10 @@

})
```
````
### Optionally request the format you want (e.g full (default), raw, minimal, metadata)
```
// Optionally request the format you want (e.g full (default), raw, minimal, metadata)
````javascript
var Gmail = require('node-gmail-api')
, gmail = new Gmail(<KEY>)
, gmail = new Gmail(accessToken)
, s = gmail.messages('label:inbox', {format: 'raw'})

@@ -56,6 +75,7 @@

})
```
````
License
=======
ISC
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc