To download the last 10 photos from Google photos, do the first 2 steps of quickstart , insert the client secret, client id and redirect to coffeescript below and run it. ( npm install --global coffeescript then coffee quickstart.coffee to run or coffee -c quickstart.coffee to compile in javascript)
I think the user should connect their google google account using google drive for this.
Help (v3) and Google’s shared drive tips:
- do not forget the
auth object when calling api functions requiring authentication: service.files.list({auth:auth, other params here...},callback) - if you forget, it returns a Daily Limit for Unauthenticated Use Exceeded error - Each file has many properties, but in v3 Api it does not return all resource fields by default. You must specify them using the
fields parameter as follows: service.files.get({auth:auth,fileId:"1y3....",fields:"mimeType, webContentLink, webViewLink, thumbnailLink"},callback) - if you want to download the file, put
alt:"media" in the options - you can request files with the
q option. Check out serach options available . Note that you can combine and embed a search through and , or and not . - there are no real "folders" on the Google drive. each file can have several "parents".
- you can get the identifiers of all folders by calling
service.files.list with the query option q:'mimeType = "application/vnd.google-apps.folder"' - to get a folder by name, use the query
q:'name = "<name of folder>" and mimeType = "application/vnd.google-apps.folder"' - you can get the root folder identifier by calling
service.files.get({auth:auth, fileId:"root"},callback) - but you can just use root where you would put that id - to list all things in a call to the root folder
service.files.list({auth:auth,q:'parents in "root"'},callback) - If you have a file identifier, you can get the file folder by calling
service.files.get with the fields:"parents" option - you have a folder identifier, you can get the files of this folder by calling
service.files.list with the query option q:'parents in "0B7..."' (note that id needs "..." ) - listing files in a folder with the tag
/one/two/three same as listing files in a three folder - but first you will need the identifier for that folder. you can get this identifier by iteratively walking along the path.
fs = require('fs') readline = require('readline') google = require('googleapis') googleAuth = require('google-auth-library') SCOPES = [ 'https://www.googleapis.com/auth/drive' ]
source share