[英]Do i require to Submit a verfication request for the following google drive scopes in order to download a file from picker?
Do i require to Submit a verification request for the following google drive scopes in order to download a file from picker? 我是否需要提交以下Google驱动器范围的验证请求,才能从选择器中下载文件?
The picker doesn't load due to the following error 由于出现以下错误,选择器无法加载
My objective is to download a file from google drive to our website. 我的目标是从Google Drive下载文件到我们的网站。
The picker loads when i use drive.file, but when i try to download the file i get a 404 file not found error. 当我使用drive.file时,选择器会加载,但是当我尝试下载文件时,会出现404文件未找到错误。
using the google drive reference files/get on there site i can simulate the 404 but if i change the scope to using just drive or drive.readonly i get a 200 status which is what i'm after but the picker does not load. 使用谷歌驱动器参考文件/在那里获得网站,我可以模拟404,但如果我将范围更改为仅使用drive或drive.readonly,我将得到200状态,这是我要的状态,但选择器无法加载。
Is there a way around this without having to submit a verification request form? 有没有解决此问题的方法而不必提交验证请求表?
The code i'm using is based of google drive sample code. 我使用的代码基于Google Drive示例代码。
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Picker Example</title> <script type="text/javascript"> // The Browser API key obtained from the Google Developers Console. var developerKey = ''; // The Client ID obtained from the Google Developers Console. Replace with your own Client ID. var clientId = "" // Scope to use to access user's photos. var scope = ['https://www.googleapis.com/auth/drive']; var pickerApiLoaded = false; var oauthToken; // Use the API Loader script to load google.picker and gapi.auth. function onApiLoad() { gapi.load('auth', {'callback': onAuthApiLoad}); gapi.load('picker', {'callback': onPickerApiLoad}); } function onAuthApiLoad() { window.gapi.auth.authorize( { 'client_id': clientId, 'scope': scope, 'immediate': false }, 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() { var view = new google.picker.DocsView(); view.setIncludeFolders(true); if (pickerApiLoaded && oauthToken) { var picker = new google.picker.PickerBuilder(). addView(view). setOAuthToken(oauthToken). setDeveloperKey(developerKey). setCallback(pickerCallback). build(); picker.setVisible(true); } } // A simple callback implementation. function pickerCallback(data) { debugger; var url = 'nothing'; var id = ""; if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) { var doc = data[google.picker.Response.DOCUMENTS][0]; url = doc[google.picker.Document.URL]; id = doc[google.picker.Document.ID]; } var accessToken = gapi.auth.getToken().access_token; var xhr = new XMLHttpRequest(); var url = "https://www.googleapis.com/drive/v3/files/" + id + "?alt=media"; xhr.open('GET', url); xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken); xhr.send(); //var message = 'You picked: ' + url; //document.getElementById('result').innerHTML = message; } </script> </head> <body> <div id="result"></div> <!-- The Google API Loader script. --> <script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script> </body> </html>
First, I suggest using the https://www.googleapis.com/auth/drive to have full scope. 首先,我建议使用https://www.googleapis.com/auth/drive来具有完整范围。 Then, show us what the code, how are you doing it? 然后,向我们展示代码,您如何做?
You didn't set the scope in the variable picker 您没有在变量选择器中设置范围
var picker = new google.picker.PickerBuilder().
addView(view).
addView(google.picker.ViewId.DOCS).//<== add this
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.