I could use fetch() to read a google sheet single value is ok. However, when tried reading multiple ranges, get error 403.
This code works fine:
values = values = fetch(`https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${sheetName}?key=${apiKey}`)
.then(
response => response.json()
)
.then (data => console.dir (data))
.catch(
error => console.error(‘Google Sheet Reading Error: ‘, error)
);
when replace the fetch() with values.getBatch, Browser’s Inspect panel displays error 403:
values = fetch(`https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values:batchGet?ranges=Sheet1!A1:A2&ranges=subtitle!B1:B2?key=${apiKey}`)
The error is:
code: 403
message: "Method doesn't allow unregistered callers (callers without established identity). Please use API Key or other form of API consumer identity to call this API."
status: "PERMISSION_DENIED"