Question

I'm building a webapp where a user can Authorize via OAuth2 and choose/upload files from their own Drive for later use. Essentially we're just storing the file ID and using the API to access them later. Everything is working fine when I use .setAuthUser() and require users to be logged in independent of our app, but when we use .setOAuthToken() instead only the file picker works — the DocsUploadView panel returns an "undefined" error.

This behavior is consistent across Firefox/Chrome/Safari and with or without a current user login. It's always able to see files, never able to upload them. We are requesting full drive scope but even with that we're seeing errors.

For now we're just using setAuthUser as a workaround but this causes extra steps and a few problems when a user isn't logged in. Is it possible to use setOAuthToken with DocsUploadView?

The picker builder code I'm using is below, with IDs and tokens in the same format I'm using but altered for security.

Thanks!

var view = new google.picker.View(google.picker.ViewId.DOCS);
var uploadview = new google.picker.DocsUploadView();  
var picker = new google.picker.PickerBuilder()
     .enableFeature(google.picker.Feature.MINE_ONLY)
     .disableFeature(google.picker.Feature.NAV_HIDDEN)
     .disableFeature(google.picker.Feature.MULTISELECT_ENABLED)
     .setAppId('987654321098')
     .setOAuthToken('ya31.AIER6DRhxRgRsT0SoGPoaxPMhDd0n3OHKj43SJaG5kFndZ52')
     .addView(uploadview)
     .addView(view)
     .setCallback(pickerCallback)
     .build();
picker.setVisible(true);

[cross-posted at: https://groups.google.com/d/topic/google-picker-api/p9whgDscUrQ/discussion]

Was it helpful?

Solution

The Picker API doesn't currently support uploads using OAuth tokens. I filed an internal feature request for this to be implemented, but for the moment you should keep relying on your workaround.

OTHER TIPS

This even SOUNDS stupid, but what about order of execution in the chaining?

.addView(uploadview)
.addView(view)

becomes

.addView(view)
.addView(uploadview)

Another thing I might suggest here is to enable multi_select on the picker

enableFeature(google.picker.Feature.NAV_HIDDEN)
enableFeature(google.picker.Feature.MULTISELECT_ENABLED)

, just to test that there's not a bug in dependency on either of those features.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top