0

I want to download files from google drive picker. I am using google drive picker and select file. it return me these parameters

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"

I have read, I need oAuthToken fileId but didn't get oAuthToken and fileId. Please let me know where can i get this ?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449

1 Answers1

0

Based from this documentation, your application must send an OAuth 2.0 token when creating a Picker object with views that accesses private user data. You may refer with this related thread wherein it stated that:

  • You can get oAuthToken from JS client side when user authenticates.

If you use the example from Google docs, the function looks like this:

function handleAuthResult(authResult) {
    if (authResult && !authResult.error) {
        oauthToken = authResult.access_token;
        oauthToken; // <-- THIS IS THE Bearer token
        createPicker();
        }
}
  • You can get fileId when user picks a file.

A modified example from Google docs.

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

Hope this helps!

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59