Skip to content

Instantly share code, notes, and snippets.

@ScottG489
Last active October 26, 2020 03:53
Show Gist options
  • Save ScottG489/b6d134d37dcbb4e8f9e07aca48a9cde1 to your computer and use it in GitHub Desktop.
Save ScottG489/b6d134d37dcbb4e8f9e07aca48a9cde1 to your computer and use it in GitHub Desktop.
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