node-samples: Cannot destructure property 'client_secret' of 'credentials.installed' as it is undefined.

Expected Behavior

Get an URL to authenticate google account

Actual Behavior

`const {client_secret, client_id, redirect_uris} = credentials.installed; ^

TypeError: Cannot destructure property ‘client_secret’ of ‘credentials.installed’ as it is undefined. at authorize (D:\Anonymous mail\anonymous-mail\backend\functions\gmail.js:26:12) at D:\Anonymous mail\anonymous-mail\backend\functions\gmail.js:16:5 ?[90m at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)?[39m `

Steps to Reproduce the Problem

?

Specifications

  • Node version 12.16.1
  • OS (Windows)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 15

Most upvoted comments

In the code change “credentials.installed” to “credentials.web”

@shaikh-amaan-fm after correcting “.installed” to “.web”,it produces another error.

      client_id, client_secret, redirect_uris[0]);
                                             ^

TypeError: Cannot read property '0' of undefined
    at authorize (/home/spidy/Desktop/SpidySys./sheetsApi/server.js:31:46)
    at fs.readFile (/home/spidy/Desktop/SpidySys./sheetsApi/server.js:19:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

I think at the time of creating credentials.json, you didn’t put any redirect URI. Create credentials.json file again from developers console and add a redirect URI.

I was getting the same error but I solved the issue by selecting a “Desktop app” when running the Quickstart locally, instead of selecting “Web Browser” during Step 1: Turn on the Google Sheets API.

A new credentials.json sheet was downloaded, imported into the project, and solved my problem.