OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Google Sheets, JWT client with Service Account

  • Thread starter Thread starter jldupont
  • Start date Start date
J

jldupont

Guest
I am pulling my hair out ! Help !! UPDATE: I am using v1.0.0 of google-auth-library and v24.0.0 of googleapis.

Code:
const { JWT } = require('google-auth-library');
var google = require('googleapis');
var sheets = google.sheets('v4');

const client = new JWT({
  email: keys.client_email
  ,key: keys.private_key
  ,scopes: ['https://spreadsheets.google.com/feeds']
});

return new Promise(function(resolve, reject) {

  client.authorize()
  .then((obj) => {

  // fails at this call
  sheets.spreadsheets.values.append({

    auth: client
    ,range: "A1"
    ,spreadsheetId: SHEET_ID
    ,insertDataOptions: "INSERT_ROWS"
    ,responseDateTimeRenderOption: "FORMATTED_STRING"
    ,responseValueRenderOption: "UNFORMATTED_VALUE"
    ,valueInputOption: "RAW"
    ,resource: {
      values: [
        [1,2,3]
      ]
    }

....... code omitted for clarity

I keep getting:

'json' is not a valid configuration option. Please use 'data' instead. This library is using Axios for requests. Please see https://github.com/axios/axios to learn more about the valid request options. at Object.validate (/user_code/node_modules/google-auth- library/build/src/options.js:32:19) at DefaultTransporter.request (/user_code/node_modules/google-auth-library/build/src/transporters.js:49:23) at JWT. (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:427:63) at step (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:57:23) at Object.next (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:38:53) at fulfilled (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:29:58) at process._tickDomainCallback (internal/process/next_tick.js:135:7)

<p>I am pulling my hair out ! Help !!
UPDATE: I am using v1.0.0 of google-auth-library and v24.0.0 of googleapis.</p>

<pre><code>const { JWT } = require('google-auth-library');
var google = require('googleapis');
var sheets = google.sheets('v4');

const client = new JWT({
email: keys.client_email
,key: keys.private_key
,scopes: ['https://spreadsheets.google.com/feeds']
});

return new Promise(function(resolve, reject) {

client.authorize()
.then((obj) => {

// fails at this call
sheets.spreadsheets.values.append({

auth: client
,range: "A1"
,spreadsheetId: SHEET_ID
,insertDataOptions: "INSERT_ROWS"
,responseDateTimeRenderOption: "FORMATTED_STRING"
,responseValueRenderOption: "UNFORMATTED_VALUE"
,valueInputOption: "RAW"
,resource: {
values: [
[1,2,3]
]
}
</code></pre>

<p>....... code omitted for clarity</p>

<p>I keep getting:</p>

<p>'json' is not a valid configuration option. Please use 'data' instead. This library is using Axios for requests. Please see
<a href="https://github.com/axios/axios" rel="noreferrer">https://github.com/axios/axios</a> to learn more about the valid request
options. at Object.validate (/user_code/node_modules/google-auth-
library/build/src/options.js:32:19) at DefaultTransporter.request (/user_code/node_modules/google-auth-library/build/src/transporters.js:49:23) at JWT. (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:427:63) at step (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:57:23) at Object.next (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:38:53) at fulfilled (/user_code/node_modules/google-auth-library/build/src/auth/oauth2client.js:29:58) at process._tickDomainCallback (internal/process/next_tick.js:135:7)</p>
 

Latest posts

Top