【问题标题】:want to download file from google drive picker想从谷歌驱动器选择器下载文件
【发布时间】:2017-02-23 16:35:33
【问题描述】:

我想从谷歌驱动器选择器下载文件。我正在使用谷歌驱动器选择器并选择文件。它返回我这些参数

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。请告诉我在哪里可以买到这个?

【问题讨论】:

    标签: angularjs google-api google-drive-api google-oauth


    【解决方案1】:

    基于此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]);
        }
    }
    

    希望这会有所帮助!

    【讨论】:

    • 我正在获取 access_token 和文件 ID,但我无法从谷歌驱动器下载文件:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-05
    • 2018-07-21
    • 1970-01-01
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多