I am trying to use apiGoogle Node.js client library to access the Google Drive API so I can upload some files to my drive account.
My code so far:
var drive = google.drive({ version: 'v3' });
drive.apiKey = "API_KEY"
drive.setScope = "https://www.googleapis.com/auth/drive.file"
drive.files.create({
resource: {
name: 'text.text',
mimeType: 'text/plain',
parents:['1ATscm2nsE9KpjA66iXHB9jnMrbyik7PP']
},
media: {
mimeType: 'text/plain',
body: fs.createReadStream('files/text.text')
}
});
Errors:
errors:
[ { domain: 'global',
reason: 'required',
message: 'Login Required',
locationType: 'header',
location: 'Authorization' } ] }
Can anybody help to resolve this issue?