想要从谷歌驱动器选取器下载文件
问题描述:
我想从谷歌驱动器选取器下载文件。我正在使用谷歌驱动器选择器和选择文件。还给我这些参数想要从谷歌驱动器选取器下载文件
https://github.com/softmonkeyjapan/angular-google-picker
$$hashKey : "009"
description : ""
embedUrl : "https://docs.google.com/uc?id=0Bz9ps73AlkCwZkp6RzNaSWhCbEU&export=download"
iconUrl :"https://ssl.gstatic.com/docs/doclist/images/icon_12_pdf_list.png"
id : "0B32ps73232wZk3236RzNaSWhCbEU"
lastEditedUtc : 14873223312734
mimeType : "application/pdf"
name: "ABCs.pdf"
parentId : "0AD93223AlkC32O789A"
serviceId : "DoclistBlob"
sizeBytes: 13754
type: "file"
url: "https://docs.google.com/document/d/KVASPSyy4f7gRurmm8W7YqKh-Lqb_Rc/edit?usp=drive_web"
我看过了,我需要oAuthToken FILEID但没有得到oAuthToken和FILEID。请让我知道我在哪里可以得到这个?
答
根据此documentation,您的应用程序必须在创建具有访问私人用户数据视图的Picker
对象时发送OAuth 2.0令牌。您可以使用此related thread参考,其中就指出:
- 您可以从JS客户端获得
oAuthToken
当用户进行身份验证。
如果从Google docs使用示例,函数如下:
function handleAuthResult(authResult) { if (authResult && !authResult.error) { oauthToken = authResult.access_token; oauthToken; // <-- THIS IS THE Bearer token createPicker(); } }
- 你可以得到
fileId
当用户选择一个文件。
来自Google文档的修改示例。
function pickerCallback(data) { if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) { var doc = data[google.picker.Response.DOCUMENTS][0]; alert('You picked fileId: ' + doc[google.picker.Document.ID]); } }
希望这有助于!
我geting access_token和文件ID,但我无法从谷歌驱动器下载文件:( –