How to use the drive function from googleapis

Find comprehensive JavaScript googleapis.drive code examples handpicked from public code repositorys.

43
44
45
46
47
48
49
50
51
52
    })
  }
}

function getPictureFolder (cb) {
  var drive = Google.drive('v3')
  drive.files.list({
    q: "mimeType='application/vnd.google-apps.folder' and name = 'Camera Pictures'",
    fields: 'nextPageToken, files(id, name)',
    spaces: 'drive',
fork icon53
star icon175
watch icon26

+ 5 other calls in file

30
31
32
33
34
35
36
37
38
39
}


// setup oauth client
const google = require('googleapis');
const GDrive = google.drive({ version: 'v2' });
const OAuth2Client = google.auth.OAuth2;
const oauth2Client = new OAuth2Client(config.clientId || "520595891712-6n4r5q6runjds8m5t39rbeb6bpa3bf6h.apps.googleusercontent.com"  , config.clientSecret || "cNy6nr-immKnVIzlUsvKgSW8", config.redirectUrl || "urn:ietf:wg:oauth:2.0:oob");
oauth2Client.setCredentials(config.accessToken);
google.options({ auth: oauth2Client });
fork icon21
star icon72
watch icon15

59
60
61
62
63
64
65
66
67
68
// logger.verbose(require('util').inspect(gAuth, { depth: null }))
return new Promise(function (resolve, reject) {
  if (notInstOfAuth) {
    const initedGAuth = new google.auth.OAuth2(gAuth.clientId_, gAuth.clientSecret_, gAuth.redirectUri_)
    initedGAuth.setCredentials(gAuth.credentials)
    global.drive = google.drive({
      version: 'v3',
      auth: initedGAuth
    })
    resolve()
fork icon5
star icon38
watch icon8

+ 3 other calls in file

12
13
14
15
16
17
18
19
20
21
22
    .join("\n"),
  target
);


const getGalleryFiles = async () => {
  const drive = google.drive({
    version: "v3",
    auth: jwt,
  });
  return drive.files.list({
fork icon0
star icon0
watch icon2

24
25
26
27
28
29
30
31
32
33

In `1.0` the same thing can be accomplished like this:

``` js
var google = require('googleapis');
var drive = google.drive('v2'); // no network call! :)
// drive.files.insert...
```

All APIs are immediately accessible without requiring discovery.
fork icon0
star icon0
watch icon7

203
204
205
206
207
208
209
210
211
``` js
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);

var drive = google.drive({ version: 'v2', auth: oauth2Client });
```

See the [Options section][options] for more information.
fork icon0
star icon0
watch icon6