I am working to add the Google Picker to my Sheets add-on so it will be prepared for the new drive scopes. I think it may be a good thing and should make the add-on more user friendly. I tried to publish an experimental version of my add-on as unlisted in the Chrome store and just to my domain in the G Suite Marketplace. I can get the add-on installed from the Chrome store and all the previous features seem to work fine. I am attempting to get the Google Picker to authorize and open my drive files using an example from Picker Guides (https://developers.google.com/picker/docs/).
I am currently stuck on the OAuth process and seem to be confused or not to understand exactly how to set up the Google Cloud Platform / APIs & Services / Credentials area. There is a yellow caution sign next to the Apps Script Client ID that states “This automatically generated OAuth client ID is required for your project. It can't be modified”. I enabled the Picker API and set the HTTP referrers to https://*.google.com & https://*.googleusercontent.com.
I am under the impression this should be what is needed, but I am getting a "redirect_uri_mismatch" error saying the Javascript origin of xx...xx.googleusercontent.com does not match the ones authorized for the OAuth client.
I also seem to be having issues in the Google Cloud Platform / G Suite Marketplace SDK with some options that I am not able to save or change in the configure & publish section and not being able to update in the Publish section. Any help or ideas would be appreciated.
<script src="https://apis.google.com/js/api.js?onload=onApiLoad"></script><!-- This is for the file picker -->
<script>
var DEVELOPER_KEY = 'Your developer key';//Replace with the API key obtained
// from the Google Developers Console
var DIALOG_DIMENSIONS = {width: 600, height: 425};
var PICKER_API_LOADED = false;
function onApiLoad() {
/**
* Load the Google Picker API
*/
gapi.load('picker', {'callback': function() {
PICKER_API_LOADED = true;
}});
}
view = new google.picker.DocsView();//google.picker.ViewId.SPREADSHEETS
view.setMode(google.picker.DocsViewMode.LIST).setMimeTypes("application/vnd.google-apps.spreadsheet");
view.setEnableSharedDrives(true);
picker = new google.picker.PickerBuilder()
// Instruct Picker to display only spreadsheets in Drive- For other
// views, see https://developers.google.com/picker/docs/#otherviews
.addView(view)// Hide the navigation panel so that Picker fills more of the dialog
.enableFeature(google.picker.Feature.NAV_HIDDEN)// Hide the title bar since an Apps Script dialog already has a title
.hideTitleBar()
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(AlanWells.googPkrFileSelected)
.setOrigin(google.script.host.origin)
// Instruct Picker to fill the dialog, minus 2 pixels for the border.
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
picker.setVisible(true);