Skip to main content
scottm29310603
Inspiring
June 17, 2019
Question

Node.js Google Sheet

  • June 17, 2019
  • 1 reply
  • 1044 views

You might have seen this in another forum, but I'm trying to aim this differently with the question.

So i've built a CEP based on this tutorial (Note this is for testing, so my actual plugin will be integrated)

https://medium.com/adobetech/how-to-build-a-node-js-server-in-a-panel-ba1d63ea67e2

Currently I open my plugin (index.html)

I have a sign in button

portion from index.html

<button id="sign-in">sign in</button>

This contacts my index.js

portion from index.js

var signButton = document.querySelector("#sign-in");

signButton.addEventListener("click", signIn);

function signIn(){

  csInterface.openURLInDefaultBrowser("http://localhost:3200/localServer.html");

}

this opens up a browser to sign into google api, but once accessed it remains in the browser like so. The actual localServer.html doesn't update that is in my folder.

portion from localServer.html (This is portion that finds the bits and put it into the pre tag)

<pre id="content" style="white-space: pre-wrap;">TRY THIS</pre>

function listMajors() {

        gapi.client.sheets.spreadsheets.values.get({

          spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',

          range: 'Class Data!A2:E',

        }).then(function(response) {

          var para = appendPre(JSON.stringify(response.result.values[0]));

          //alert(response.result.values[1][0]);

        }, function(response) {

          appendPre('Error: ' + response.result.error.message);

        });

      }

Can anyone suggest either an easier way to pull the data in my index.html or index.js or communicate the data back into my index.html or index.js from the browser imaged above.

I can't believe I can get all this data and information, yet I can't pass it to use.

Incase anyone is thinking why I need to do it this way and not using a public Google Sheet.

My plugin, launches a script. this then takes the Google Sheet rows one at a time. Duplicates the comp, changes the data based on the rows. This is where I need to have the Google API Oauth signed in. It then updates the Column specified from Ready to Done.

I've done tests on a local WebServer on mac that does all this great, then I put it into my plugin, The plugin in doesn't allow me to login in the panel, which then lead me to launch it in a web browser and send back the data, but now I can communicate back the data. So anyone who has done this or has any ideas would be appreciated.

This topic has been closed for replies.

1 reply

stevek52428324
Participating Frequently
June 18, 2019

Can you use webscoket and/or `csEvent`? Either way, I don't think you would need a whole node js server running for it. I can send you an example without node if you are interested

scottm29310603
Inspiring
June 18, 2019

If you can send an example that would be fantastic.

This is out of my realm.

Anything outside of JavaScript and HTML (even these I'm not a pro) are limited.

How would you use a csEvent? That's what I've been looking for to be fair.

stevek52428324
Participating Frequently
June 18, 2019
let csEvent = new CSEvent();

      csEvent.type = "com.example.sender";

      csEvent.scope = "APPLICATION";

      csEvent.appId = csInterface.getApplicationID();

      csEvent.extensionId = csInterface.getExtensionID();

      csEvent.data = "Auth completed";

      csInterface.dispatchEvent(csEvent);