Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Google Picker #5443

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Draft: Google Picker #5443

wants to merge 1 commit into from

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Sep 2, 2024

Initial POC of Google Picker.

closes #5382
closes #5469

How to test:

Google Developer console setup

Instructions for enabling the Picker API in the Google Developer console for the first time:

Now set VITE_GOOGLE_PICKER_CLIENT_ID, VITE_GOOGLE_PICKER_API_KEY, VITE_GOOGLE_PICKER_APP_ID in your .env file and run yarn dev:with-companion

Problems/discussion

  • redirect_uri needs to be frontend URI, and wilcard is not allowed. Update: I've made appId, clientId and apiKey as Uppy options (not Companion) so this should be OK because people can then use their own credentials.
  • UI is not very good, wraps weirdly etc
  • No deep/multi select inside folders like we have now with Uppy
  • Cannot seem to be able to select drives shared with me
  • Cannot seem to get google photos to work (only Google Drive)
  • In the end I decided not to put it in RemoteSources because it has different options

TODO

  • tsconfig.json (I have just copy-pasted from google photos)
  • tsconfig.build.json (I have just copy-pasted from google photos)
  • google-picker.mdx (I have just copy-pasted from google photos)
  • google-picker/README.md (I have just copy-pasted from google photos)
  • in onPicked add the files along with any metadata needed by companion to download the files, like accessToken, clientId etc.
  • Create a new endpoint in companion to allow downloading files and pass the files along with parameters like clientId, scope, accessToken. The endpoint will call gapi.client.drive.files.get, and stream (download/upload) the file to the destination (e.g. tus/s3 etc). Need to make sure the endpoint is secure somehow in a way that it cannot be abused/exploited.
  • maybe this.provider is not needed in GooglePicker.ts
  • Need to save the auth token somewhere? (local storage?)

Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

🚮 Removed packages: npm/lodash@4.17.21), npm/process@0.11.10), npm/tslib@2.7.0)

View full report↗︎

Copy link
Contributor

github-actions bot commented Sep 2, 2024

Diff output files
diff --git a/packages/@uppy/provider-views/lib/index.js b/packages/@uppy/provider-views/lib/index.js
index 3e5b730..319f9c4 100644
--- a/packages/@uppy/provider-views/lib/index.js
+++ b/packages/@uppy/provider-views/lib/index.js
@@ -1,2 +1,3 @@
+export { default as GooglePickerView } from "./GooglePicker/index.js";
 export { default as ProviderViews, defaultPickerIcon } from "./ProviderView/index.js";
 export { default as SearchProviderViews } from "./SearchProviderView/index.js";
diff --git a/packages/@uppy/transloadit/lib/index.js b/packages/@uppy/transloadit/lib/index.js
index 5d77af0..6e48521 100644
--- a/packages/@uppy/transloadit/lib/index.js
+++ b/packages/@uppy/transloadit/lib/index.js
@@ -458,6 +458,7 @@ function _getClientVersion2() {
   addPluginVersion("Facebook", "uppy-facebook");
   addPluginVersion("GoogleDrive", "uppy-google-drive");
   addPluginVersion("GooglePhotos", "uppy-google-photos");
+  addPluginVersion("GooglePicker", "uppy-google-picker");
   addPluginVersion("Instagram", "uppy-instagram");
   addPluginVersion("OneDrive", "uppy-onedrive");
   addPluginVersion("Zoom", "uppy-zoom");

Comment on lines +97 to +98
// NOTE: photos is broken and results in an error being returned from Google
// .addView(google.picker.ViewId.PHOTOS)

Choose a reason for hiding this comment

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

This is an old method of using Google Picker I believe @mifi. There is a new picker API for Google Photos and I believe it'll have to be a separate implementation: https://developers.google.com/photos/picker/guides/get-started-picker

At least how it appears to work is by making a POST request to https://photospicker.googleapis.com/v1/sessions which returns a few things including a pickerUri which can then the user can select photos in another tab/window using that URI from their Google Photos library for all photos and albums: https://developers.google.com/photos/picker/reference/rest/v1/sessions/create

However, I don't think Google allows you to access shared albums, etc. anymore at all unfortunately. So it just has to be something the user has in their library or album directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup I just found out about it too, i've done some testing and it seems to be working. It's a pity that shared albums don't work, but what can we do

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.

Google Photos API Deprecation Mar. 31, 2025 Implement Google Picker API
2 participants