-
-
Save ScottG489/b6d134d37dcbb4e8f9e07aca48a9cde1 to your computer and use it in GitHub Desktop.
Using the Google Drive API with Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"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