Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google sheets API with chrome extension, how to use?

I am making my first chrome extension. My idea is to call Google Sheets API to append a row in a google spreadsheet from my extension. I am referring this link for the same and successfully tried the API to append row in my desired sheet.

Now I am trying to do the same from my chrome extension code files. How do you use the same sample code for your extension as our extension will not allow inline js. Any sample or basic boilerplate would help.

Many thanks in advance.

like image 367
Shyam Kansagra Avatar asked Jan 19 '18 06:01

Shyam Kansagra


Video Answer


2 Answers

You are receiving that error because of the inline JavaScript.
Chrome Extensions do not allow any inline scripting. Read Here.

Inline JavaScript will not be executed
Inline JavaScript will not be executed. This restriction bans both inline blocks and inline event handlers (e.g. ).

So any JavaScript must come from its own .js file.
It is common to use popup.html and all JavaScript for that page in popup.js.
Same goes for options.html and options.js.


Helpful Links:
Chrome Extension and Google Sheets
Tutorial for using OAuth

like image 53
Jay A. Little Avatar answered Sep 21 '22 09:09

Jay A. Little


https://github.com/malik55khan/speardsheet-reader/

Demo: https://www.loom.com/share/d7d432c513a44b05a615fa0bd170fb23

Create a client-auth key in google console and select chrome extension. after that push the project id and save it. then you will get client_id. Next step create a api key.

add a new project. - select google cloud or Spreadsheet - Enable API.

Hope it will be more helpful.

like image 44
MALIK KHAN Avatar answered Sep 21 '22 09:09

MALIK KHAN