randomBrainstormer / MMM-GoogleCalendar

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

Step 5 & 6 #3

Closed che575757ak closed 2 years ago

che575757ak commented 2 years ago

Hi, Excited to get your module for our family google calendar in MM. I am a super beginner and can't understand what to do in step 5 & 6.

  1. Run authenticate.js: node authenticate.js.
  2. Follow the instructions and it should print your calendar. Copy the ID of the calendar you want to the config.

Could you describe this in a bit more details, where do i run this, how? Thank you!

randomBrainstormer commented 2 years ago

Hi @che575757ak,

In step 5 you have to run the script for authentication, this means you have to:

  1. Open the Terminal. Check out this article that shows how to do that.
  2. Navigate to the directory where you installed this module. You can check out the section titled "Changing directories in Terminal" in the linked article. Basically, you have to use the cd command to navigate to the module directory, in my case magic mirror is in the root directory, so I type cd ./magic-mirror/modules/MMM-GoogleCalendar.
  3. Once you're in the module directory just type the command node authenticate.js. This will run the script contained in authenticate.js.

Step 6 is just following the indications that are shown once you run the node authenticate.js command, it will basically show an URL which you have to copy and paste in your browser, it will take you to a google auth page and you just have to authenticate and authorize the module, once authenticated the page will show you a code which you will have to copy and paste as it is back in the terminal.

Once completed, if everythings ok your calendar(s) ID and the events will print to the console. You can copy the calendar ID from the message in the console or you can also find it on your google calendar page by going to the settings). The calendarID is the value that you'll set in magic mirror's config/config.js

Hope I was able to help! Let me know if you were succesful!

che575757ak commented 2 years ago

Thank you so much for replying! I will try your suggestion in the next few days and let you know how i make out. Thanks again!

che575757ak commented 2 years ago

Hi Again, I did as you kindly described and I get the following: pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleCalendar $ node authenticate.js node:internal/modules/cjs/loader:936 throw err; ^

Error: Cannot find module '/home/pi/MagicMirror/modules/MMM-GoogleCalendar/authenticate.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleCalendar $

Any idea what i am doing wrong? Got to it sooner than expected as I was excited to get it to work! Thanks!

randomBrainstormer commented 2 years ago

Hi! according to the error the module is not found. Try and check if you're in the right directory, try using this command: ls it will list the files in the current directory, if you're in the right place you should see a file called authenticate.js, otherwise you got to navigate to the modules directory and execute node authenticate.js inside the MMM-GoogleCalendardirectory

che575757ak commented 2 years ago

Hi, There is a file called "authorize.js" nothing named "authenticate.js". Shall i use "node authorize.js" or change file name to "authenticate.js" then use your command "node authenticate.js"? Thanks!

daha1989 commented 2 years ago

I am facing the same issue..

pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleCalendar $ ls authorize.js calendar.css credentials.json LICENSE MMM-GoogleCalendar.js node_helper.js README.md

that are the files inside MMM-GoogleCalendar. Maybe I/we made been mistakes during Authentication Setup? Do we need to conduct every single step of the 4 described in the Prerequisites

and do we need to conduct the following steps of Node.js quickstart - Step 1: Install the client library Run the following commands to install the libraries using npm: ...... as well?

randomBrainstormer commented 2 years ago

@che575757ak yes, my mistake it should be node authorize.js not node authenticate.js, thanks for pointing that out, also thanks to @georgeismike for submitting the fix.

che575757ak commented 2 years ago

Hi, Just ran the "node authorize.js" and i get the following:

pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleCalendar $ node authorize.js /home/pi/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. at authorize (/home/pi/MagicMirror/modules/MMM-GoogleCalendar/authorize.js:26:11) at /home/pi/MagicMirror/modules/MMM-GoogleCalendar/authorize.js:16:3 at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleCalendar $

I really don't know what it means. I have the credentials.json downloaded file plus the OAuth 2 Client enabled.

Thanks...

randomBrainstormer commented 2 years ago

Hi @che575757ak,

This error is basically saying that the credentials file is not what this module is expecting, it could be one of two issues:

  1. The calendar API is not enabled in the google cloud project, check if is enabled here.
  2. The credentials are not for a web application. Probably the credential was set for TV application and not web application. Try creating a new credential and select web application as type. Redownload and execute node authorize.js again.

Let me know how it goes!

che575757ak commented 2 years ago

Hi, I have enabled API and shows "enabled" I recreated the credentials for web application and ran node authorize.js but getting same exact error as above. Sorry but maybe I don't know enough to make this work! Thanks!

randomBrainstormer commented 2 years ago

@che575757ak wait, actually I got the type wrong...😅 sorry for the confusion! I was goign by memory 😅, the right credential type is actually TV and unlimited input. This should get the module working now : )

Also, I will be adding a troubleshooting guide with these errors and all experience gathered from this thread, so new users can have an easier time setting this up, I appreciate your feedback and updates!

randomBrainstormer commented 2 years ago

@che575757ak were you able to get this working?

getchethanbr commented 2 years ago

Hi, This module is working great for one google account calendar. How do I add calendar from another google account? Should I follow all the process again in that google account (like creating project in google developer console) ??

Please help, thanks in advance.

randomBrainstormer commented 2 years ago

@getchethanbr this question is off topic, please open a new issue with your question

randomBrainstormer commented 2 years ago

Closing this issue for now, feel free to open a new issue if you need any help