-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
40 lines (31 loc) · 1.04 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const {google} = require( 'googleapis' )
const Batch = require( '.' )
const clientCredentials = require( './.client-secret.json' )
const credentials = require( './.credentials.json' )
const client = new google.auth.OAuth2(
( clientCredentials.web || clientCredentials.installed ).client_id,
( clientCredentials.web || clientCredentials.installed ).client_secret
)
client.setCredentials( {
access_token: 'noop',
refresh_token: credentials.refresh_token,
expiry_date: Date.now() - 3600000 * 24 * 7,
} )
const gmail = google.gmail( {
version: 'v1'
} )
/*
*/
gmail.users.messages.list( { userId: 'me', auth: client, maxResults: 1 }, ( err, response ) => {
console.log( "NORMAL", err, response.data )
} )
/*
*/
const batch = new Batch( client )
gmail.users.messages.list( { userId: 'me', auth: batch, maxResults: 1 }, ( err, response ) => {
console.log( "ONE", err, response.data )
} )
gmail.users.messages.list( { userId: 'me', auth: batch, maxResults: 2 }, ( err, response ) => {
console.log( "TWO", err, response.data, response )
} )
batch.exec()