MMM-GoogleCalendar icon indicating copy to clipboard operation
MMM-GoogleCalendar copied to clipboard

I am frequently running into invalid_grant issue which usually goes away with regenerating token ? Is there a way to fix this problem permanently?

Open randomBrainstormer opened this issue 4 years ago • 6 comments

hi @randomBrainstormer, I am frequently running into invalid_grant issue which usually goes away with regenerating token ? Is there a way to fix this problem permanently?

Originally posted by @letsandeepio in https://github.com/randomBrainstormer/MMM-GoogleCalendar/issues/9#issuecomment-1026131221

randomBrainstormer avatar Feb 01 '22 09:02 randomBrainstormer

hi @letsandeepio,

Unfortunately, we can't control the invalid_granterror, this is returned by google whenever they think there's an issue with the token, and this can be something as little as going offline for 1 second or asking for too many requests. Example of other reasons here.

Currently, I don't have a way to fix this problem permamently, as soon as I can figure something out I would definitely push it to the repo.

Some things to try out in the meantime is the fetchInterval option, setting it a higher interval (15 mins) can help lower the load.

randomBrainstormer avatar Feb 02 '22 09:02 randomBrainstormer

I've been thinking for a possible solution for this problem and got two ideas to explore:

  1. Google allows you to renew the token without the need of user input using the current credential type (TV and unlimited input). This could pontentially save us from getting invalid_grant so often.
  2. Try using a different type of credential (other than TV and Unlimited Input). This won't solve the invalid_grant issue directly, but rather force us to change the authorization flow and possibly integrate some kind of "Log in" feature in the module's UI. It would at least make the authorization process more simple.

I'll try to run some tests when I have some more free time

randomBrainstormer avatar Feb 14 '22 17:02 randomBrainstormer

hi randomBrainstormer, I love your module, but experience the same problem every 1 or 2 weeks.

The widget shows 'Error in the MMM-GoogleCalendar Module. Check logs for more details.' Then, I go to the module directory

'cd ~/MagicMirror/modules/MMM-GoogleCalendar/MMM-GoogleCalendar.js`

Remove the token.json

'rm token.json'

Regenerate the token and follow instructions by running

'node authorize.js'

To prevent doing this every week, I just implemented your suggested workaround of changing the fetchInterval value, I did it like this:

nano ~/MagicMirror/modules/MMM-GoogleCalendar/MMM-GoogleCalendar.js

changed value from: fetchInterval: 5 * 60 * 1000, to fetchInterval: 15 * 60 * 1000,

I hope it works.

Keep up the good work!

Raeymeister avatar Feb 22 '22 19:02 Raeymeister

I figured out recently that by moving the Google app project to Production, this issue of invalid_grant requiring authorizing again every week or so, gets solved. Haven't had to reauthorize in a long time now.

sidevesh avatar Mar 30 '23 21:03 sidevesh

I figured out recently that by moving the Google app project to Production, this issue of invalid_grant requiring authorizing again every week or so, gets solved. Haven't had to reauthorize in a long time now.

I know that was a while ago, but do you remember how you did that exactly? I don't know if it is because the coffee hasn't kicked in yet, but I'm not finding how to do that?

Milkysunshine avatar Nov 28 '23 16:11 Milkysunshine

@Milkysunshine You have to go google cloud console where you set up the magic mirror app. Once you get to your app find the OAuth consent screen. There is a publishing status where it will probably say Testing. If you push publish app you will move it to production. I would be very careful and read exactly what you are doing and ensure that you have your permissions set appropriately before you publish the app.

nobbie25 avatar Dec 11 '23 20:12 nobbie25