Google Drive (Picker) API not showing viewable filesHow to have multiple scopes with Google Calendar + Google DriveGoogle Picker API DocsUploadView setIncludeFolders not workingIs there a link to the “latest” jQuery library on Google APIs?Google Drive SDK Mobile integration queryGetting Google file picker to work with drive.file scopeGoogle file picker example breaks when you choose different view e.g. google.picker.ViewId.DOCSOauth2 Google Drive offline access not working for non-google app files?How to read Drive Photos using Drive Rest APIHow to get a direct download URL from Google Picker JavaScript API?Do i require to Submit a verfication request for the following google drive scopes in order to download a file from picker?Google Drive API Picker v3 (May 2018) window disappears and gives .split is not a function errorHow to auth Google Drive api from Android using access token received from server
What (else) happened July 1st 1858 in London?
Some numbers are more equivalent than others
Why has "pence" been used in this sentence, not "pences"?
How much character growth crosses the line into breaking the character
Can I use my Chinese passport to enter China after I acquired another citizenship?
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
Reply 'no position' while the job posting is still there
Melting point of aspirin, contradicting sources
How do I implement a file system driver driver in Linux?
Will adding a BY-SA image to a blog post make the entire post BY-SA?
How should I respond when I lied about my education and the company finds out through background check?
Do the concepts of IP address and network interface not belong to the same layer?
Can somebody explain Brexit in a few child-proof sentences?
Visiting the UK as unmarried couple
Engineer refusing to file/disclose patents
Java - What do constructor type arguments mean when placed *before* the type?
Why is Arduino resetting while driving motors?
Could the E-bike drivetrain wear down till needing replacement after 400 km?
Did arcade monitors have same pixel aspect ratio as TV sets?
Fly on a jet pack vs fly with a jet pack?
Why did the HMS Bounty go back to a time when whales are already rare?
A social experiment. What is the worst that can happen?
Find last 3 digits of this monster number
Is it possible to use .desktop files to open local pdf files on specific pages with a browser?
Google Drive (Picker) API not showing viewable files
How to have multiple scopes with Google Calendar + Google DriveGoogle Picker API DocsUploadView setIncludeFolders not workingIs there a link to the “latest” jQuery library on Google APIs?Google Drive SDK Mobile integration queryGetting Google file picker to work with drive.file scopeGoogle file picker example breaks when you choose different view e.g. google.picker.ViewId.DOCSOauth2 Google Drive offline access not working for non-google app files?How to read Drive Photos using Drive Rest APIHow to get a direct download URL from Google Picker JavaScript API?Do i require to Submit a verfication request for the following google drive scopes in order to download a file from picker?Google Drive API Picker v3 (May 2018) window disappears and gives .split is not a function errorHow to auth Google Drive api from Android using access token received from server
I'm setting up a Google Picker API (subset of Drive API) button in my Rails 4.2 application to show viewable images and document files. I can login to Google Drive, select and access the upload modal without issue; however, on selection, the file url is displayed under the button as part of my callback, but no file is viewable.
Thanks for looking; the picker docs (https://developers.google.com/picker/docs/) are amazingly out of date, and what I've managed so far that actually works is sourced of derived from SO:
Google Picker API DocsUploadView setIncludeFolders not working
How to have multiple scopes with Google Calendar + Google Drive
Here is the code thus far - can anyone tell me what's missing from my callback to complete the view flow?
<script type="text/javascript">
// The Browser API key obtained from the Google API Console.
var developerKey = "<%= ENV.fetch('GOOGLE_DEV_KEY') %>";
// The Client ID obtained from the Google API Console. Replace with your own Client ID.
var clientId = "<%= ENV.fetch('GOOGLE_CLIENT_ID') %>";
var appId = "<%= ENV.fetch('GOOGLE_APP_ID') %>";
// Scope to use to access user's photos.
var scope = 'https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/photoslibrary.readonly';
//rWpDLsvXoNFGzsqsa28G8Cq7
var pickerApiLoaded = false;
var oauthToken;
// Use the API Loader script to load google.picker and gapi.auth.
function onApiLoad()
console.log('onApiLoad')
gapi.load('auth2', onAuthApiLoad);
gapi.load('picker', onPickerApiLoad);
function onAuthApiLoad()
var authBtns = document.getElementsByClassName('auth');
Array.from(authBtns).forEach(function(authBtn)
authBtn.disabled = false;
authBtn.addEventListener('click', function()
gapi.auth2.authorize(
client_id: clientId,
scope: scope
, handleAuthResult);
);
)
function onPickerApiLoad()
pickerApiLoaded = true;
createPicker();
function handleAuthResult(authResult)
if (authResult && !authResult.error)
oauthToken = authResult.access_token;
createPicker();
// Create and render a Picker object for picking user Photos.
function createPicker()
if (pickerApiLoaded && oauthToken)
var picker = new google.picker.PickerBuilder().
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
enableFeature(google.picker.Feature.MINE_ONLY).
setAppId(appId).
setOAuthToken(oauthToken).
addView(google.picker.ViewId.DOCS_IMAGES).
addView(google.picker.ViewId.DOCS).
addView(new google.picker.DocsUploadView().setIncludeFolders(true)).
setCallback(pickerCallback).
build();
picker.setVisible(true);
// A simple callback implementation.
function pickerCallback(data)
var url = 'nothing';
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED)
var doc = data[google.picker.Response.DOCUMENTS][0];
url = doc[google.picker.Document.URL];
var message = 'You picked: ' + url;
document.getElementById('result').innerHTML = message;
window.addEventListener('DOMContentLoaded', function()
console.log('loaded!')
onApiLoad()
)
</script>
<%= content_for(:google_api_loader) do %>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>
<% end %>
javascript ruby-on-rails-4 google-drive-sdk google-picker google-drive-picker
add a comment |
I'm setting up a Google Picker API (subset of Drive API) button in my Rails 4.2 application to show viewable images and document files. I can login to Google Drive, select and access the upload modal without issue; however, on selection, the file url is displayed under the button as part of my callback, but no file is viewable.
Thanks for looking; the picker docs (https://developers.google.com/picker/docs/) are amazingly out of date, and what I've managed so far that actually works is sourced of derived from SO:
Google Picker API DocsUploadView setIncludeFolders not working
How to have multiple scopes with Google Calendar + Google Drive
Here is the code thus far - can anyone tell me what's missing from my callback to complete the view flow?
<script type="text/javascript">
// The Browser API key obtained from the Google API Console.
var developerKey = "<%= ENV.fetch('GOOGLE_DEV_KEY') %>";
// The Client ID obtained from the Google API Console. Replace with your own Client ID.
var clientId = "<%= ENV.fetch('GOOGLE_CLIENT_ID') %>";
var appId = "<%= ENV.fetch('GOOGLE_APP_ID') %>";
// Scope to use to access user's photos.
var scope = 'https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/photoslibrary.readonly';
//rWpDLsvXoNFGzsqsa28G8Cq7
var pickerApiLoaded = false;
var oauthToken;
// Use the API Loader script to load google.picker and gapi.auth.
function onApiLoad()
console.log('onApiLoad')
gapi.load('auth2', onAuthApiLoad);
gapi.load('picker', onPickerApiLoad);
function onAuthApiLoad()
var authBtns = document.getElementsByClassName('auth');
Array.from(authBtns).forEach(function(authBtn)
authBtn.disabled = false;
authBtn.addEventListener('click', function()
gapi.auth2.authorize(
client_id: clientId,
scope: scope
, handleAuthResult);
);
)
function onPickerApiLoad()
pickerApiLoaded = true;
createPicker();
function handleAuthResult(authResult)
if (authResult && !authResult.error)
oauthToken = authResult.access_token;
createPicker();
// Create and render a Picker object for picking user Photos.
function createPicker()
if (pickerApiLoaded && oauthToken)
var picker = new google.picker.PickerBuilder().
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
enableFeature(google.picker.Feature.MINE_ONLY).
setAppId(appId).
setOAuthToken(oauthToken).
addView(google.picker.ViewId.DOCS_IMAGES).
addView(google.picker.ViewId.DOCS).
addView(new google.picker.DocsUploadView().setIncludeFolders(true)).
setCallback(pickerCallback).
build();
picker.setVisible(true);
// A simple callback implementation.
function pickerCallback(data)
var url = 'nothing';
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED)
var doc = data[google.picker.Response.DOCUMENTS][0];
url = doc[google.picker.Document.URL];
var message = 'You picked: ' + url;
document.getElementById('result').innerHTML = message;
window.addEventListener('DOMContentLoaded', function()
console.log('loaded!')
onApiLoad()
)
</script>
<%= content_for(:google_api_loader) do %>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>
<% end %>
javascript ruby-on-rails-4 google-drive-sdk google-picker google-drive-picker
add a comment |
I'm setting up a Google Picker API (subset of Drive API) button in my Rails 4.2 application to show viewable images and document files. I can login to Google Drive, select and access the upload modal without issue; however, on selection, the file url is displayed under the button as part of my callback, but no file is viewable.
Thanks for looking; the picker docs (https://developers.google.com/picker/docs/) are amazingly out of date, and what I've managed so far that actually works is sourced of derived from SO:
Google Picker API DocsUploadView setIncludeFolders not working
How to have multiple scopes with Google Calendar + Google Drive
Here is the code thus far - can anyone tell me what's missing from my callback to complete the view flow?
<script type="text/javascript">
// The Browser API key obtained from the Google API Console.
var developerKey = "<%= ENV.fetch('GOOGLE_DEV_KEY') %>";
// The Client ID obtained from the Google API Console. Replace with your own Client ID.
var clientId = "<%= ENV.fetch('GOOGLE_CLIENT_ID') %>";
var appId = "<%= ENV.fetch('GOOGLE_APP_ID') %>";
// Scope to use to access user's photos.
var scope = 'https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/photoslibrary.readonly';
//rWpDLsvXoNFGzsqsa28G8Cq7
var pickerApiLoaded = false;
var oauthToken;
// Use the API Loader script to load google.picker and gapi.auth.
function onApiLoad()
console.log('onApiLoad')
gapi.load('auth2', onAuthApiLoad);
gapi.load('picker', onPickerApiLoad);
function onAuthApiLoad()
var authBtns = document.getElementsByClassName('auth');
Array.from(authBtns).forEach(function(authBtn)
authBtn.disabled = false;
authBtn.addEventListener('click', function()
gapi.auth2.authorize(
client_id: clientId,
scope: scope
, handleAuthResult);
);
)
function onPickerApiLoad()
pickerApiLoaded = true;
createPicker();
function handleAuthResult(authResult)
if (authResult && !authResult.error)
oauthToken = authResult.access_token;
createPicker();
// Create and render a Picker object for picking user Photos.
function createPicker()
if (pickerApiLoaded && oauthToken)
var picker = new google.picker.PickerBuilder().
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
enableFeature(google.picker.Feature.MINE_ONLY).
setAppId(appId).
setOAuthToken(oauthToken).
addView(google.picker.ViewId.DOCS_IMAGES).
addView(google.picker.ViewId.DOCS).
addView(new google.picker.DocsUploadView().setIncludeFolders(true)).
setCallback(pickerCallback).
build();
picker.setVisible(true);
// A simple callback implementation.
function pickerCallback(data)
var url = 'nothing';
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED)
var doc = data[google.picker.Response.DOCUMENTS][0];
url = doc[google.picker.Document.URL];
var message = 'You picked: ' + url;
document.getElementById('result').innerHTML = message;
window.addEventListener('DOMContentLoaded', function()
console.log('loaded!')
onApiLoad()
)
</script>
<%= content_for(:google_api_loader) do %>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>
<% end %>
javascript ruby-on-rails-4 google-drive-sdk google-picker google-drive-picker
I'm setting up a Google Picker API (subset of Drive API) button in my Rails 4.2 application to show viewable images and document files. I can login to Google Drive, select and access the upload modal without issue; however, on selection, the file url is displayed under the button as part of my callback, but no file is viewable.
Thanks for looking; the picker docs (https://developers.google.com/picker/docs/) are amazingly out of date, and what I've managed so far that actually works is sourced of derived from SO:
Google Picker API DocsUploadView setIncludeFolders not working
How to have multiple scopes with Google Calendar + Google Drive
Here is the code thus far - can anyone tell me what's missing from my callback to complete the view flow?
<script type="text/javascript">
// The Browser API key obtained from the Google API Console.
var developerKey = "<%= ENV.fetch('GOOGLE_DEV_KEY') %>";
// The Client ID obtained from the Google API Console. Replace with your own Client ID.
var clientId = "<%= ENV.fetch('GOOGLE_CLIENT_ID') %>";
var appId = "<%= ENV.fetch('GOOGLE_APP_ID') %>";
// Scope to use to access user's photos.
var scope = 'https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/photoslibrary.readonly';
//rWpDLsvXoNFGzsqsa28G8Cq7
var pickerApiLoaded = false;
var oauthToken;
// Use the API Loader script to load google.picker and gapi.auth.
function onApiLoad()
console.log('onApiLoad')
gapi.load('auth2', onAuthApiLoad);
gapi.load('picker', onPickerApiLoad);
function onAuthApiLoad()
var authBtns = document.getElementsByClassName('auth');
Array.from(authBtns).forEach(function(authBtn)
authBtn.disabled = false;
authBtn.addEventListener('click', function()
gapi.auth2.authorize(
client_id: clientId,
scope: scope
, handleAuthResult);
);
)
function onPickerApiLoad()
pickerApiLoaded = true;
createPicker();
function handleAuthResult(authResult)
if (authResult && !authResult.error)
oauthToken = authResult.access_token;
createPicker();
// Create and render a Picker object for picking user Photos.
function createPicker()
if (pickerApiLoaded && oauthToken)
var picker = new google.picker.PickerBuilder().
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
enableFeature(google.picker.Feature.MINE_ONLY).
setAppId(appId).
setOAuthToken(oauthToken).
addView(google.picker.ViewId.DOCS_IMAGES).
addView(google.picker.ViewId.DOCS).
addView(new google.picker.DocsUploadView().setIncludeFolders(true)).
setCallback(pickerCallback).
build();
picker.setVisible(true);
// A simple callback implementation.
function pickerCallback(data)
var url = 'nothing';
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED)
var doc = data[google.picker.Response.DOCUMENTS][0];
url = doc[google.picker.Document.URL];
var message = 'You picked: ' + url;
document.getElementById('result').innerHTML = message;
window.addEventListener('DOMContentLoaded', function()
console.log('loaded!')
onApiLoad()
)
</script>
<%= content_for(:google_api_loader) do %>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>
<% end %>
javascript ruby-on-rails-4 google-drive-sdk google-picker google-drive-picker
javascript ruby-on-rails-4 google-drive-sdk google-picker google-drive-picker
edited Mar 8 at 19:38
Boucherie
asked Mar 8 at 6:50
BoucherieBoucherie
315213
315213
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058111%2fgoogle-drive-picker-api-not-showing-viewable-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058111%2fgoogle-drive-picker-api-not-showing-viewable-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown