It is used to build client libraries, IDE plugins, and other tools that interact with Google APIs. One service may provide multiple discovery documents. This service provides the following...
A parameter in a data source's query. The parameter allows the user to pass in values from the spreadsheet into a query. { "name": string, // Union field value can be only one of the following:...
I believe you are missing API in the url. This is from google spreadsheet api doc.
To acquire an API key:
Open the Credentials page in the API Console.
API keys: A request that does not provide an OAuth 2.0 token must send an API key. The key identifies your project and provides API access, quota, and reports.
The API supports several types of restrictions on API keys. If the API key that you need doesn't already exist, then create an API key in the Console by clicking Create credentials > API key. You can restrict the key before using it in production by clicking Restrict key and selecting one of the Restrictions. To keep your API keys secure, follow the best practices for securely using API keys.
After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.
The API key is safe for embedding in URLs; it doesn't need any encoding.
Google Spreadsheet Docs
How about this modification?
headers using the access token.body for giving the title of created spreadsheet.request({
method: 'POST',
uri: 'https://sheets.googleapis.com/v4/spreadsheets?fields=properties%2Ftitle%2CspreadsheetId',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken,
},
body: JSON.stringify({properties: {title: "sampleTitle"}}),
}, (error, response, body) => {
console.log(body);
});
https://www.googleapis.com/auth/spreadsheets to the scopes. This scope is used to create the spreadsheet.How about this sample? of Advanced Google services is used like Sheets.Spreadsheets.Values.append(). So the sample used your parameters is as follows.Sheets.Spreadsheets.Values.append(resource, spreadsheetId, range, optionalArgs)
var resource = {
"majorDimension": "ROWS",
"values": [[new Date()]]
}
var spreadsheetId = "### SpreadsheetID ###";
var range = "Sheet1!A:A";
var optionalArgs = {valueInputOption: "USER_ENTERED"};
Sheets.Spreadsheets.Values.append(resource, spreadsheetId, range, optionalArgs);