I have been trying to read and write data to a private Google spreadsheet from a private notebook.
I have forked this notebook (thanks again, Grant ) and managed to sign-in into my Google account.
When I try to access my Google spreadsheet with the gapi object it returns an array of 2 (range?) objects that is shortly black, but then turns red.
In the Chrome console I find these two error messages:
Iâd love to - but according to the documentation the scopes are limited to file read-only. And I also need to write to it. Could I extend the scopes myself ?
What puzzles me, too, is the fact that when I initially tried this, I am sure it did work. I just cannot reproduce it anymore.
Every now and then I also get an error message like âunauthorized daily quota exceededâ from my many trials & errors âŚ
After you do an oauth handshake, you get a token. You can test that token in isolation using google developer API playground. I highly recommend that resource for developing google API intergrations.
You can also obtain the token in the playground and pass that to your application to figure out exactly where the issue is. Itâs just handy having a working system to compare against.
The Service account looks like a perfect fit for me, which Iâll try next.
But could it be that the issue that I am having is actually caused by this Observable notebook page load error that I just discovered ?
Below youâll see the Chrome console output that I get already when I start a brandnew notebook:
this is not using Google API client (GAPI) though, but I think the token can be passed to the GAPI client. (oh mine uses webcode.run to store a client secret, its the webserver flow, kinda simpler IMHO)
When I try to import these two lines of your script on top notebook level
import fs = require(âfsâ);
import {JWT, auth} from âgoogle-auth-libraryâ;
I get the error message âunable to load moduleâ. And I donât find the google-auth-library, either.
Do you happen to have alternative import statements for me, or what could I do instead ?
I have not really generalised that notebook, maybe we should! But short term you are expected to fork it and mess about with the apiKey and discovery doc settings.
I have been using Google OAuth with AWS Cognito Identity Pools to secure AWS resources such as Lambda functions and itâs been working like a charm except on mobile (Google OAuth Javascript API doesnât seem to support mobile?). For my Google Cloud project, my authorized Javascript origin for OAuth is https://gnestor.static.observableusercontent.com, gnestor being my Observable handle, so you just need to replace that with your own handle. You donât need to set an âauthorized redirect URI.â After you update our OAuth credentials, copy the âClient IDâ from the console and use it as your clientId variable in the notebook. Lastly, be sure that you have enabled the sheets API in the âEnabled API & Servicesâ section of the console and that https://www.googleapis.com/auth/spreadsheets is included in your scopes. I hope this helps