Authentication to access a Google Sheet with JavaScript

41 views
Skip to first unread message

samuel.ma...@bbva.com

unread,
Sep 24, 2015, 2:20:47 PM9/24/15
to Google Visualization API
I'm trying to read the info from a GoogleSheets with TableTop

I was able to have this done as far as my GoogleSheets is from a personal account and I make it public.

However, if I'm trying to access to a document from a company account (event I made the document public) I'm having an error.

I'm guessing I need some type of Authentication to get the data from the document but have not clue how to do that.

Any help would be highly appreciated. 

I'm including the whole code below but my guess is that what it needs to be added for Authentication has to be done within the few next lines

THANKS!!!!



  function init() {
    Tabletop.init( { key: public_spreadsheet_url,
                     callback: showInfo,
                     simpleSheet: true } )   




All Code



<html>
 
<head>
   
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
   
<script type="text/javascript" src="tabletop.js"></script>
   
<script type="text/javascript">
      google
.load("visualization", "1.1", {packages:["table"]});
     




  window
.onload = function() { init() };


 
//var token = gapi.auth.getToken().access_token;
 
var public_spreadsheet_url = 'https://docs.google.com/a/bbva.com/spreadsheets/d/1ynZQBIvaR6B1BokXke-mA62g5Oe3eRECugy2zV_JOj4/pubhtml?gid=1727641883&single=true';


 
function init() {
   
Tabletop.init( { key: public_spreadsheet_url,
                     callback
: showInfo,
                     simpleSheet
: true } )  


 
}


 
function showInfo(data, tabletop) {
    console
.log(data);


   
var i =0;
   
var valorSystems = data [i].Systems;


   
do {
       
var x = document.getElementById("SelectSystems");
       
var option = document.createElement("option");
        option
.text = valorSystems;
        option
.value = valorSystems;
        x
.add(option);
        i
++
        valorSystems
= data [i].Systems;
       
}
 
   
while (valorSystems != '');


}






 
</script>
 
</head>
 
<body>
   
<select id="SelectSystems">




   
</select>
 
</body>
</html>








Reply all
Reply to author
Forward
0 new messages