Skip to content

[WV-2665] Add Google Drive OAuth utility for Cordova app download and BrowserStack video upload#4725

Open
tarunramireddy wants to merge 5 commits intowevote:developfrom
tarunramireddy:google-drive-oauth-cordova-app-download-upload-utility
Open

[WV-2665] Add Google Drive OAuth utility for Cordova app download and BrowserStack video upload#4725
tarunramireddy wants to merge 5 commits intowevote:developfrom
tarunramireddy:google-drive-oauth-cordova-app-download-upload-utility

Conversation

@tarunramireddy
Copy link
Contributor

@tarunramireddy tarunramireddy commented Mar 11, 2026

Summary:

What

Adds a shared OAuth 2.0 utility for Google Drive access and two reusable CLI utilities built on top of it:

  1. downloadAppsFromDriveApi.js — Downloads APK and IPA files from a Google Drive folder to the local apps/ directory for use with BrowserStack Cordova testing.
  2. uploadVideosToDriveFromBrowserStack.js — Fetches a BrowserStack session video by session ID and uploads it to a designated Google Drive folder for product demo review.
  3. googleDriveOAuth.js — Shared helper that handles OAuth 2.0 authentication with a cached token. First run opens an interactive browser prompt; all subsequent runs use the cached refresh token automatically.

How to use

  1. Copy googleDriveOAuth.config.template.js → googleDriveOAuth.config.js and fill in your OAuth client credentials from Google Cloud Console.
  2. Run either utility once — a browser window will open to authenticate. Token is cached automatically.
npm run drive:download
npm run drive:upload-video -- <BROWSERSTACK_SESSION_ID>

Files changed

  • utils/googleDriveOAuth.js — new shared OAuth helper
  • utils/downloadAppsFromDriveApi.js — new download utility
  • utils/uploadVideosToDriveFromBrowserStack.js — new upload utility
  • specs/DownloadVideo.browser.js — refactored to delegate to shared utility
  • config/googleDriveOAuth.config.template.js — setup template (credentials not included)
  • config/googleDriveOAuthToken.template.js — documents auto-generated token shape
  • .gitignore — excludes OAuth config and token files
  • package.json — adds drive:download and drive:upload-video scripts

…ack video upload

- Add shared googleDriveOAuth.js helper with cached token and interactive first-run browser flow
- Add downloadAppsFromDriveApi.js to download APK/IPA from a Drive folder to the local apps directory
- Add uploadVideosToDriveFromBrowserStack.js to fetch a BrowserStack session video and upload to a Drive folder
- Refactor DownloadVideo.browser.js to delegate to the shared upload utility
- Add googleDriveOAuth.config.template.js and googleDriveOAuthToken.template.js for setup guidance
- Add drive:download and drive:upload-video npm scripts
- Update .gitignore to cover OAuth config and token files
Copilot AI review requested due to automatic review settings March 11, 2026 03:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Google Drive OAuth-based utilities under tests/browserstack_automation/ to (1) download Cordova app binaries (APK/IPA) from a Drive folder and (2) upload BrowserStack session videos to a Drive folder, replacing prior service-account based access patterns.

Changes:

  • Introduces a shared Google Drive OAuth helper with local-browser auth and cached token persistence.
  • Adds CLI utilities to download APK/IPA files from a Drive folder and upload BrowserStack session videos to Drive.
  • Refactors the existing DownloadVideo.browser.js script to delegate to the new upload utility; updates repo ignore rules and package scripts.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/browserstack_automation/utils/googleDriveOAuth.js New OAuth helper for authenticated Google Drive API client creation + token caching.
tests/browserstack_automation/utils/downloadAppsFromDriveApi.js New CLI utility to list a Drive folder and download APK/IPA to apps/.
tests/browserstack_automation/utils/uploadVideosToDriveFromBrowserStack.js New CLI utility to fetch BrowserStack session video and upload to Drive.
tests/browserstack_automation/utils/testOAuth.js Manual smoke-test script for OAuth helper.
tests/browserstack_automation/specs/DownloadVideo.browser.js Refactored to call shared upload utility instead of inlining Drive/BrowserStack logic.
tests/browserstack_automation/config/googleDriveOAuth.config.template.js Template for OAuth client credentials config.
tests/browserstack_automation/config/googleDriveOAuthToken.template.js Documentation template describing generated token JSON shape/location.
tests/browserstack_automation/config/googleDrive.config.template.js Template for Drive folder IDs/paths and listing tunables used by the utilities.
package.json Adds drive:download and drive:upload-video scripts.
.gitignore Ignores Drive config/token files and downloaded apps directory contents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…download utilities

- Restrict OAuth token file permissions to owner-readable only (mode 0o600)
- Validate REDIRECT_URI config before use to avoid low-level TypeError
- Sort APK/IPA candidates by modifiedTime (newest first) instead of arbitrary ordering
Change FOLDER_URL from '-' to empty string so that missing config
produces the intended 'Provide --folder=...' error instead of a
confusing 'Could not extract folder ID' error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants