Skip to content

Instantly share code, notes, and snippets.

@ScottG489
Last active Oct 26, 2020
Embed
What would you like to do?
Using the Google Drive API with Node.js
import {google} from 'googleapis';
const auth = new google.auth.GoogleAuth({
keyFile: './credentials.json',
scopes: ['https://www.googleapis.com/auth/drive'],
});
const drive = google.drive({version: 'v3', auth});
(async () => {
const driveResponse = await drive.files.list({
fields: '*',
});
console.log(driveResponse.data.files);
})().catch(e => {
console.log(e);
});
{
"name": "google-drive-api-project",
"version": "1.0.0",
"description": "Google Drive API with Node.js",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gist.github.com/ScottG489/b6d134d37dcbb4e8f9e07aca48a9cde1"
},
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.3",
"googleapis": "^61.0.0"
}
}
{
"compilerOptions": {
"target": "ES2015",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Recommended"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment