4 Replies Latest reply on Aug 8, 2017 1:19 PM by kerrishotts

    Google Sheets


      I've managed to get some code working to pull information off from a google sheet and onto the screen, but when I integrated it with my phoneGap project, it stopped working.  I think part of the issue is that it worked through a local host originally, but is now going through the phoneGap server, but I am uncertain as to how I should rectify this issue.  The code is meant to create something of a decision tree and is as follows:



      Left panel content goes here

      Decision Tree










                                                                                            textCol){                                       output = {titles:info[i][0], contents:info[i][1] , questions:info[i][2], done:false, answers: ans, next:course};                                 }                                 else{                                     output = {titles:info[i][0], contents:info[i][1], done:true};                                 }                                   returnVal.push(output);                                   output = "";                               }                               return returnVal;                             }                                                         function initClient() {                               var API_KEY = 'AIzaSyD1548_G7dQRFH7us5ziBpOp-DRRQ3w1yk';  // TODO: Update placeholder with desired API key.                               var CLIENT_ID = '371986161218-v1ejafinod0idod1dl5jll2nrap36q5o.apps.googleusercontent.com';  // TODO: Update placeholder with desired client ID.                               // TODO: Authorize using one of the following scopes:                               //   'https://www.googleapis.com/auth/drive'                               //   'https://www.googleapis.com/auth/drive.file'                               //   'https://www.googleapis.com/auth/drive.readonly'                               //   'https://www.googleapis.com/auth/spreadsheets'                               //   'https://www.googleapis.com/auth/spreadsheets.readonly'                               var SCOPE = 'https://www.googleapis.com/auth/spreadsheets.readonly';                               gapi.client.init({                                 'apiKey': API_KEY,                                 'clientId': CLIENT_ID,                                 'scope': SCOPE,                                 'discoveryDocs': ['https://sheets.googleapis.com/$discovery/rest?version=v4'],                               }).then(function() {                                 gapi.auth2.getAuthInstance().isSignedIn.listen(updateSignInStatus);                                 updateSignInStatus(gapi.auth2.getAuthInstance().isSignedIn.get());                               });                             }                             function handleClientLoad() {                               gapi.load('client:auth2', initClient);                             }                             function updateSignInStatus(isSignedIn) {                               if (isSignedIn) {                                 makeApiCall();                               }                             }                             function handleSignInClick(event) {                               gapi.auth2.getAuthInstance().signIn();                             }                             function handleSignOutClick(event) {                               gapi.auth2.getAuthInstance().signOut();                             }                                                                                                                                              About app                        
                                              Link 1                     Link 2                
        • 1. Re: Google Sheets
          kerrishotts Adobe Employee

          Ok -- some copy & paste looks like it went awry there. Please try that again (maybe post a link to some screenshots instead?)

          • 2. Re: Google Sheets
            KeepersIntern Level 1

            Yeah--that was not how I wanted to show that.  The main file is as such (I think this is how pastebin works): Forums Post for Decision Tree - Pastebin.comScreen Shot 2017-08-07 at 10.15.01.png


            WhatsApp Image 2017-08-07 at 10.24.15 AM.jpeg

            The images shown above show the starting screen (on web browser--same for both) followed by the desired output for after the start button is pressed.  The second picture was achieved through hard coding, and I would like to be able to pull the code from google sheets instead of typing it in myself.  The code presented in the link should show my attempt at reading the google sheet correctly.  Additionally, while the start button works on android, it does not do anything on my web browser, and I am not sure why.  How may I fix these issues?  Hopefully this better shows what my issues are.

            • 3. Re: Google Sheets
              KeepersIntern Level 1

              Edit: I did notice the issue on line 115.  It was a copy/paste issue and is not representative of the issues with the code.

              • 4. Re: Google Sheets
                kerrishotts Adobe Employee

                Your content-security-policy meta tag looks like it will restrict any access to the Google Sheet. If you debug your app with Chrome/Safari while connected to your app (either on sim or device), you should be seeing CSP violations in the JS console.


                Also check the whitelist in your config.xml. If you've not configured one, you need to do so. If you want to share your config.xml, be sure to scrub any private/secret info.