randomBrainstormer / MMM-GoogleCalendar

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

no authorize.js output due to running in docker remotely #26

Open alucarddelta opened 1 year ago

alucarddelta commented 1 year ago

Hey,

I am not running magic mirror locally on a raspberry pi but on my main unraid server in a docker container for ease of syncing up multiple screens.

Because of this, I can only access the command line remotely when configuring my modules.

Is there a way to run the node authorize.js and complete the installation?

mmcc-xx commented 1 year ago

For what it is worth I'm having the same problem. I'm not sure that running "npm install" in the module directory is the right thing either given the docker environment.

stevehurcombe commented 1 year ago

I have a similar problem.

I'm running MM on a Pi Zero, as per these instructions: https://thesmarthomejourney.com/2022/09/02/magicmirror%c2%b2-on-pi-zero-w/#Using_a_the_MagicMirror_scripts

I therefore have similar problems being unable to launch a browser.

Maybe there's a way to get the launch URL so the xserver Oliver uses could be used?

jasonpranevicius commented 1 year ago

Hey guys, I've just recently started using magicmirror for the first time and had this problem. I'm running magicmirror in docker via my Synology, here's what I did to fix:

I have my config/modules/css folders on a share on my Synology that are mounted to magicmirror on startup. This is so I can update the image and not lose any config.

Prereqs:

Steps:

  1. Connect to the share on the computer where you installed node, so you can browse the files i.e. using finder, windows explorer etc.
  2. Open a terminal to the folder where authorize.js is
  3. Run node authorize.js
  4. Wait about 30 seconds, and your browser will automatically open so you can auth

Sorry if this is hard to read. Happy to clarify anything if you need.

sidevesh commented 1 year ago

Here's a a bit of a hacky script that I wrote to tackle this for my setup, might be helpful for others, I have a slack workspace for my home server to get important notifications and stuff, this script allows me to have a channel on slack to get a prompt to relogin at which point I can login on any device from anywhere and just paste the final OAuth grant url as a reply at which point this script calls it locally to then relogin into google account. Just replace the xdg-open file in node_modules/ open directory inside of the MMM-GoogleCalendar module's location with this, set your slack bot token and channel name as env vars SLACK_TOKEN and SLACK_CHANNEL for the container and now run node authorize.js from ssh or any other way and you should get a prompt on slack to relogin with the instructions https://gist.github.com/sidevesh/46f0727791b358fcd88992cb21833fc7

The following scopes will have to be provided for the slack bot:

channels:history
channels:read
chat:write
groups:history
im:history
mpim:history

This may be too specific to my setup but I hope this helps out someone out there!

WinkelmannVictor commented 1 year ago

I'm trying to use your solution @sidevesh but it seems that I'm doing something wrong, I can't see any logging in the console when running authorize.js so I can't figure out what's wrong, it posts to slack but does not seem to do anything when the link is pasted in the thread as a reply, have you seen this bug before? I've looked at the bot's permissions but it should work. any tips? :D

sidevesh commented 1 year ago

@WinkelmannVictor I am almost certain that its a case of all the right permissions not having being provided to the bot, can you share a list of all the oauth scopes you have set for the bot ?

sidevesh commented 1 year ago

the script also creates a log file in tmp, you can look into where that is exactly in the script and check the contents of the log to see if you can debug the issue.

WinkelmannVictor commented 1 year ago

@sidevesh just solved the issue... OMG feel so stupid... I forgot to invite the bot to the channel....

mirrormonark commented 1 year ago

hi everybody. when Open a terminal to the folder where authorize.js is Run node authorize.js

he say me not authorize and block

Errore 403: access_denied Richiedi dettagli: access_type=offline response_type=code redirect_uri=http://localhost:xxxx/ client_id=xxxxxt.apps.googleusercontent.com scope=https://www.googleapis.com/auth/calendar.readonly

jbryan2010 commented 1 year ago

Hey guys, I've just recently started using magicmirror for the first time and had this problem. I'm running magicmirror in docker via my Synology, here's what I did to fix:

I have my config/modules/css folders on a share on my Synology that are mounted to magicmirror on startup. This is so I can update the image and not lose any config.

Prereqs:

  • You will need node installed on a separate machine
  • You will need to have your credentials.json copied to the directory before you start

Steps:

  1. Connect to the share on the computer where you installed node, so you can browse the files i.e. using finder, windows explorer etc.
  2. Open a terminal to the folder where authorize.js is
  3. Run node authorize.js
  4. Wait about 30 seconds, and your browser will automatically open so you can auth

Sorry if this is hard to read. Happy to clarify anything if you need.

I THINK I was able to get this method to work for Unraid using a Windows PC. To expand on it a bit: On the Windows machine, run cmd.exe: run cmd.exe npm install node

Then run PowerShell.exe: cd \unraidipaddress\appdata\magicmirror2\modules\MMM-GoogleCalendar node authorize.js

I had to wait roughly a minute before the browser opened up to complete the install. However, I do still have something wrong as my MM docker is continually crashing/restarting when I include the module in the config.

Note: This also assumes you have the proper permissions set up in Unraid to access the server this way.