randomBrainstormer / MMM-GoogleCalendar

Google Calendar for MagicMirror²
MIT License
64 stars 45 forks source link

Cannot destructure property 'client_secret' #12

Closed s14774 closed 2 years ago

s14774 commented 2 years ago

Hi! I tried to authorize, but it is looking like I have wrong structure of credentials.json Error:

/home/pi/GIT/MagicMirror/modules/MMM-GoogleCalendar/authorize.js:26
  const { client_secret, client_id, redirect_uris } = credentials.installed;
          ^

TypeError: Cannot destructure property 'client_secret' of 'credentials.installed' as it is undefined.

structure of credentials.json

{
  "web":{
    "client_id":"x",
    "project_id":"y",
    "auth_uri":"https://accounts.google.com/o/oauth2/auth",
    "token_uri":"https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
    "client_secret":"z",
    "redirect_uris":["z"]
  }
}
s14774 commented 2 years ago
function authorize(credentials, callback) {
  const { client_secret, client_id, redirect_uris } = credentials.web;

With that everything is looking good.

Authorized, but cannot run:

[14.02.2022 17:14.21.109] [ERROR] TypeError: Cannot destructure property 'client_secret' of 'credentials.installed' as it is undefined.
    at authorize (/home/pi/GIT/MagicMirror/modules/MMM-GoogleCalendar/node_helper.js:61:15)
    at /home/pi/GIT/MagicMirror/modules/MMM-GoogleCalendar/node_helper.js:51:7
s14774 commented 2 years ago

All working after read: make sure to create a credential for TV and unlimited input Advice: add this info to set up guide.