randomBrainstormer / MMM-GoogleCalendar

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

Unexpected token var #6

Closed Wdave40 closed 2 years ago

Wdave40 commented 2 years ago

Hey, So, I have fumbled my way to the point of running it I have errors and when I run a config check I get [ERROR] line 135 column 3: Parsing error: Unexpected token var. (line 135 is 'var config = {') I just copied and pasted what was there.

Any ideas? I am stumped.

var config = { modules: [ ... { module: 'MMM-GoogleCalendar', header: "My Google Private Cal", position: "top_left", config: { calendars: [ { symbol: "calendar-week", calendarID: "GoogleCalendarID" }, { symbol: "calendar-alt", calendarID: "MyOtherGoogleCalID" // other "calendar" options }, ], ... // other "configuration" options } }, ... ] }

randomBrainstormer commented 2 years ago

Hi @Wdave40!, whenever you get "parsing error" means theres probably a comma, a character or something that is not in the right place or is not part of the code. For what I see in your config you have to remove the ... from the code, they're there just for guiding, to indicate there may other things that were already there in your config file. The only part you need to copy is actual module config.

For example, if I have only 1 calendar and the google calendar ID is 123-abc my config would look like this:

{
    module: 'MMM-GoogleCalendar',
    header: "My Google Private Cal",
    position: "top_left",
    config: {
        calendars: [
            {
                symbol: "calendar-week",
                calendarID: "123-abc"
             },
         ],
    }
},

And all you have to do is put this config inside the modules section of your config.js file. If can be helpful, check out this guy adding a bitcoin module, basically just copy the config here above and replace the 123-abc with your actual ID and should work :-)

Let me know how it goes!

Wdave40 commented 2 years ago

Thank you so much for the quick reply. I will give that a try. I'll also check out the video, but that is adding another layer, hopin that doesn't confuse a newbie even more.

Wdave40 commented 2 years ago

Well!! it's on my dashboard!! Thank you. I don't know why entering it in config.js that way made a difference but it did.

But now I have an error so my calendar isn't listing on the dashboard. It says, Error in the MMM-GoogleCalendar Module. [objectObject]

Any ideas?

Thank you again for the help. it was huge.

randomBrainstormer commented 2 years ago

Hi!!

Well, could still be the config, but is hard to tell the error is not giving any useful info. Have you tried checking the logs? there could be useful information of what exactly is the error. Try running pm2 logs mm to see the latest logs and if there's any actual error from this module, is probably easier to find the error if you restart magic mirror so the log is blank: pm2 restart mm then check once it starts pm2 logs mm . Another way to see logs is right click on the mirror and select "inspect", then select "console" in the small window that opens up, there should also be some more info on whats is causing the error.

Most times when error is not in the config, you usally just need to run step 5 again so it can authenticate with Google.

Wdave40 commented 2 years ago

You're right again!

0|mm | [14.01.2022 17:33.18.874] [LOG] Error loading client secret file: [Error: ENOENT: no such file or directory, open '/home/pi/MagicMirror/modules/MMM-GoogleCalendar/credentials.json'] { 0|mm | errno: -2, 0|mm | code: 'ENOENT', 0|mm | syscall: 'open', 0|mm | path: '/home/pi/MagicMirror/modules/MMM-GoogleCalendar/credentials.json'

I'll see if I can load my credentials again. I'm sure you'll hear from me again

Thank you I owe you a beer

Wdave40 commented 2 years ago

Should the credentials look like this?

{"installed":{"client_id":"xxxxxxxxxxxxxxxxxx-p7v4xxxxxxxxxxxxxxxxxxxv.apps.googleusercontent.com","project_id":"magicmirror-2022","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x444_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"gibberish-DOrmoregibberishSq","redirect_uris":["urn:fitwef:wg:oauth:2.0:oob","http://localhost"]}}

randomBrainstormer commented 2 years ago

Correct! that's how the credentials looks like, make sure you place that file inside MMM-GoogleCalendar directory! and also that the file is named credentials.json

Wdave40 commented 2 years ago

That's done. It had the wrong credentials in there and the wrong token. I added the correct ones but also noticed I have no URL in there and it was marked Application type for TV, I can't seem to be able to change it to web application so I will have to make a new one. What should the authorization java script origins URL be?

randomBrainstormer commented 2 years ago

Hi!!

I think correct credential type is "TV", the "web application" type might give you yet a different error.

I'm not sure what the origin url should be, but whatever value is in the credentials file when downloaded is all the module needs, just that it has to be renamed credentials.json.

If credential of type TV doesn't work try the other types and repeat the Auth step again, when it gets the right one the calendars will load!

Wdave40 commented 2 years ago

I've tried web application, TV & Limited input and desktop to no avail

I do have an alert saying there is an update available. Should I install that or just get it running first?

Wdave40 commented 2 years ago

I got it!!!!! Thank you so much. I was directing it to the wrong place

Really appreciate your help.

randomBrainstormer commented 2 years ago

Glad it works!