0

I have authenticated for google drive using passport js

Now I have access token

So I am looking for to get all folders path with their respective folder Id.

I am not aware what parameters need to set to get only folders path and folder id

I am using google-drive library for fetching lists

Here is my code

var googleDrive = require('google-drive')
 var param={}
 googleDrive(accessToken).files().list(params, (err, response, body) => {
                       //fetch folders path
                    })

Thanks.

Sam
  • 795
  • 2
  • 18
  • 31

1 Answers1

2

Try changing

var param={}

to

var param={q: "mimeType='application/vnd.google-apps.folder' and trashed=false"}

With all due respect to the authors of the library you are using, be very careful. Either a library deal with all of Drive's subtleties (eg. following nextPageTokens) or it will cause you problems. The Drive REST API is a very well formed API, and you could just as easily access it using Fetch, which, being Promise based, makes for much cleaner code and allows you to use async await.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Thanks @pinoyyid. This is working fine. but it is not showing full path for a folder – Sam Apr 26 '17 at 09:58
  • I wouldn't expect it to. Folders in Google Drive don't really have paths. See http://stackoverflow.com/questions/41741520/how-do-i-search-sub-folders-and-sub-sub-folders-in-google-drive – pinoyyid Apr 26 '17 at 11:16