{"id":18783165,"url":"https://github.com/denvaar/google-drive-api-demo","last_synced_at":"2025-07-22T22:33:47.382Z","repository":{"id":93745386,"uuid":"86266422","full_name":"denvaar/google-drive-api-demo","owner":"denvaar","description":"Simple example Electron app that uses Google's Nodejs client library for interacting with Google Drive","archived":false,"fork":false,"pushed_at":"2018-08-02T21:55:01.000Z","size":15,"stargazers_count":5,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-20T07:51:20.030Z","etag":null,"topics":["electron","google-api","react"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denvaar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-26T21:33:26.000Z","updated_at":"2023-02-07T22:34:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe51dd39-40b7-4574-b868-e8c4d56d290a","html_url":"https://github.com/denvaar/google-drive-api-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/denvaar/google-drive-api-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denvaar%2Fgoogle-drive-api-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denvaar%2Fgoogle-drive-api-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denvaar%2Fgoogle-drive-api-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denvaar%2Fgoogle-drive-api-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denvaar","download_url":"https://codeload.github.com/denvaar/google-drive-api-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denvaar%2Fgoogle-drive-api-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266586038,"owners_count":23952169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","google-api","react"],"created_at":"2024-11-07T20:38:21.823Z","updated_at":"2025-07-22T22:33:47.363Z","avatar_url":"https://github.com/denvaar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# google-drive-api-demo\nSimple example Electron app that uses [Google's Nodejs client library](https://github.com/google/google-api-nodejs-client) for interacting with Google Drive.\n\nAllows you to...\n- Authenticate the app using OAuth2 and consent page\n- Browse files from your Google Drive\n- View various details about the files\n- Download/export files\n- Upload and create new files to your Google Drive\n- Play private videos directly from your Google Drive\n\nStream Videos  | View Files and Details\n:-----:|:-----:\n\u003cimg width=380 src=\"https://cloud.githubusercontent.com/assets/10538978/24336921/cc71c1e8-1253-11e7-9c4c-921f6e04ef9c.png\" /\u003e | \u003cimg width=380 src=\"https://cloud.githubusercontent.com/assets/10538978/24336922/cc8333ce-1253-11e7-9a77-b93ccc40417f.png\" /\u003e\n\nAsk user consent  | Export \u0026 Download\n:-----:|:-----:\n\u003cimg width=380 src=\"https://cloud.githubusercontent.com/assets/10538978/24336963/7b5e46ae-1254-11e7-81c1-dd02a462e1b0.png\" /\u003e | \u003cimg width=380 src=\"https://cloud.githubusercontent.com/assets/10538978/24336924/cc8a3516-1253-11e7-90b7-9c8f016ca320.png\" /\u003e\n\n# Setup\n\n### Project Setup\n1. Run `npm install` in a console window.\n2. Next, run the npm script from `package.json` to start webpack: `npm run-script watch`\n3. In another window or tab, run `npm start` to launch the Electron app.\n4. (Optional) To package the app as a Mac OSX desktop application, you can use this: ```electron-packager ./google-drive-api-demo GoogleAPIDemo --version \u003cELECTRON VERSION\u003e --platform=darwin --out=/path/to/desired/output/directory/ --arch=all --ignore=\"(node_modules|src)\"```\n\n### Google Drive API Setup\nBefore you can use Google API's, you will need to setup your developer console. Follow step #1 of the NodeJS quickstart guide: https://developers.google.com/drive/v3/web/quickstart/nodejs\n\nOnce you have obtained a CLIENT_ID and SECRET_ID, paste them [here](https://github.com/denvaar/google-drive-api-demo/blob/master/main.js#L39).\n\n# Gotcha's\nThese are a few things that I got hung up on while working on this demo. Hopefuly I can help to clarify things for others.\n\n### Using the redirect URL\n\nThe [quickstart guide](https://developers.google.com/drive/v3/web/quickstart/nodejs) has some awesome example code of getting an OAuth token and making an authenticated request to the Drive API, but this example requires the user to copy and paste the application's authorization key from the browser to the console, which is not very cool. There is a caveat at the end that says:\n\u003eThe authorization flow in this example is designed for a command line application. For information on how to perform authorization in other contexts, see the Authorizing and Authenticating. section of the library's README.\n\nCurious to know how to do authorization in those \"other contexts,\" I visited the [library's README](https://github.com/google/google-api-nodejs-client/#authorizing-and-authenticating). The docs basically state that after the consent page, Google will do a redirect to the provided _redirect url_ with the auth code in the query parameters. This part stumped me, because I wasn't quite sure how to provide a redirect url that I could use to get the params. I had an Ah-ha moment when I realized that you can use localhost as that redirect url. That means that if you have an HTTP server running at the address, you can snatch up the auth code that you need. The `http.createServer` function in `main.js` is an example of this.\n\n### Careful passing around the OAuth data\n\nI was getting an error like this when I would try to make a request to the Drive API: ```TypeError: authClient.request is not a function```. After doing some digging, I came accross [this Stack Overflow post](http://stackoverflow.com/questions/42853532/googleapis-typeerror-authclient-request-is-not-a-function-in-nodejs), which seemed to address the issue that I was having. I think that it boiled down to the fact that I was trying to pass around the OAuth object from Nodejs code to client-side React code, and it was getting messed up. Though the SO question/answer is not toally related to my scenerio, I think the same issue was happening: things were getting stripped from the OAuth object. The solution was to keep it in a global store somewhere. So I just ended up keeping it as a global in `main.js`.\n\n\n# Resources\nI found the following links helpful while working on this demo.\n\n- Nodejs quickstart guide: https://developers.google.com/drive/v3/web/quickstart/nodejs\n- Drive API Reference: https://developers.google.com/drive/v3/reference/\n- Using OAuth2 to Access Google API's: https://developers.google.com/identity/protocols/OAuth2\n- OAuth2 for Mobile and Desktop Apps: https://developers.google.com/identity/protocols/OAuth2InstalledApp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenvaar%2Fgoogle-drive-api-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenvaar%2Fgoogle-drive-api-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenvaar%2Fgoogle-drive-api-demo/lists"}