Google picker in Electron returns 403 when packaged but not local dev

34 views Asked by At

We are running into an issue where the Google picker is working fine in our web builds and our local development Electron build, but when we go to package up a staging build, opening the picker gives us a 403 error.

Here is how we are setting up our picker:

const folderView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
folderView.setSelectFolderEnabled(true);
folderView.setLabel('My folders');

const driveView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
driveView.setSelectFolderEnabled(true);
driveView.setEnableDrives(true);
driveView.setLabel('Shared drives');

const picker = new google.picker.PickerBuilder()
    .setAppId(params.clientId)
    .setOAuthToken(params.accessToken)
    .setTitle('Select a folder')
    .setCallback(params.callbackFunction);

picker.addView(folderView);
picker.addView(driveView);
picker.build().setVisible(true);

We have already authenticated and have a valid OAuth token (and have verified it is correct).

When we execute this code, we see in the network tab it is making a document request to https://docs.google.com/picker and failing with the 403.

We investigated the difference between the successful calls and the unsuccessful ones to try and figure out what might be the root cause. To do this, we took the unsuccessful call and pasted it into a browser and saw it still fail. Then we replaced each param one at a time from the successful call and once we replaced out the parent=<path>/favicon.ico it started working in the browser. So it seems like the fact that it is a file:/// for this parent param is where the whole failure hinges.

//working dev electron url:

https://docs.google.com/picker?protocol=gadgets&
origin=http://localhost:3001&
oauth_token=<token>&
title=Select a folder&
hostId=localhost&
parent=http://localhost:3001/favicon.ico&
ifls=<token>&
nav=(("folders","My folders",{"selectFolder":true}),("folders","Shared drives",{"selectFolder":true,"dr":true}))&
rpcService=<token>&
rpctoken=<token>&
thirdParty=true


//Broken packaged electron app:

https://docs.google.com/picker?protocol=gadgets&
origin=file://&
oauth_token=<token>&
title=Select a folder&
hostId&
parent=file%3A%2F%2F%2Ffavicon.ico <----- THE OFFENDING LINE
ifls=<token>&
nav=(("folders","My folders",{"selectFolder":true}),("folders","Shared drives",{"selectFolder":true,"dr":true}))&
rpcService=<token>&
rpctoken=<token>&
thirdParty=true

Does anyone know what this parent= param does? Or how we can set it to something else? Or why it is failing when it is file%3A%2F%2F%2Ffavicon.ico? Thanks

0

There are 0 answers