[SOLVED] Google Calendar Scheduler re-authorize

I just setup Google Calendar Scheduler following the instructions on the wiki. Everything went fine.
I then decided to create a separate Google Console Project exclusively for Openhab, since I used a Google Console Project meant for a completely different project.

Hence, I revoked the access for openhab and repeated all steps in the wiki for the new project.
The problem is: the Google Calendar Scheduler somehow remembers that it already has been authorized and won’t ever show me the initalization sequence again, even though I replaced both the client id and the client secret.

What I need is this:

[INFO ] [g.internal.GCalEventDownloader] -################################################################################################
 [INFO ] [g.internal.GCalEventDownloader] - # Google-Integration: U S E R   I N T E R A C T I O N   R E Q U I R E D !!
 [INFO ] [g.internal.GCalEventDownloader] - # 1. Open URL 'https://www.google.com/device'
 [INFO ] [g.internal.GCalEventDownloader] - # 2. Type provided code ZPWT-UVXXS 
 [INFO ] [g.internal.GCalEventDownloader] - # 3. Grant openHAB access to your Google calendar
 [INFO ] [g.internal.GCalEventDownloader] - # 4. openHAB will automatically detect the permissions and complete the authentication process
 [INFO ] [g.internal.GCalEventDownloader] - # NOTE: You will only have 1800 mins before openHAB gives up waiting for the access!!!
 [INFO ] [g.internal.GCalEventDownloader] -################################################################################################

to be able to re-add the “device” to my Google devices.
I tried (de-)installing the scheduler, restarting openhab, commenting the config lines in gcal.cfg, still I get an invalid grant error (of course, since the “device” isn’t authorized by google anymore).

2017-01-29 13:27:24.293 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication failed: 400 Bad Request
{
  "error" : "invalid_grant",
  "error_description" : "Token has been expired or revoked."
}

The code reads the token that had been stored previously, and having succeeded in reading it, does not think it needs to re-authorize.

Until this is improved in some way, look for and delete the file gcal_oauth2_token. On openHAB 2.0.0 installed via apt-get, it ought to be in the location /var/lib/openhab2/gcal/gcal_oauth2_token. Stopping and restarting the bundle ought to trigger the authorization process again and then log the code to enter.

1 Like

Now everything works as expected, thank you!

1 Like

I didnt see my Auth code pop up and am not even sure it did. i do not have gcal folder in /var/lib/openhab2. does that mean i have not even received the auth code and im missing something else?

Hello!

I just tried to install the gcal scheduler but I get this error:

2018-03-08 15:40:30.137 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - ################################################################################################

2018-03-08 15:40:30.139 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # Google-Integration: U S E R   I N T E R A C T I O N   R E Q U I R E D !!

2018-03-08 15:40:30.140 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 1. Open URL 'https://www.google.com/device'

2018-03-08 15:40:30.142 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 2. Type provided code RLXT-WSQN 

2018-03-08 15:40:30.143 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 3. Grant openHAB access to your Google calendar

2018-03-08 15:40:30.145 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # 4. openHAB will automatically detect the permiossions and complete the authentication process

2018-03-08 15:40:30.147 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - # NOTE: You will only have 1800 mins before openHAB gives up waiting for the access!!!

2018-03-08 15:40:30.148 [INFO ] [openhab.io.gcal.auth.GCalGoogleOAuth] - ################################################################################################

2018-03-08 15:41:03.432 [INFO ] [b.core.service.AbstractActiveService] - Google Calendar Event Downloader has been started

2018-03-08 15:41:04.015 [ERROR] [openhab.io.gcal.auth.GCalGoogleOAuth] - authentication I/O exception: 403 Forbidden

{

  "code" : 403,

  "errors" : [ {

    "domain" : "usageLimits",

    "message" : "Project 341880040972 is not found and cannot be used for API calls. If it is recently created, enable Calendar API by visiting https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=341880040972 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",

    "reason" : "accessNotConfigured",

    "extendedHelp" : "https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=341880040972"

  } ],

  "message" : "Project 341880040972 is not found and cannot be used for API calls. If it is recently created, enable Calendar API by visiting https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=341880040972 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."

}

Any idea what I need to do now ? (I activated the Calendar API just now)

Hi, that simply means it 's not connecting and it does not give any clue to why.

I have it working perfectly so I can assure you it works when done correctly. A bit of a pain I know, I ended up on this topic a while back as I struggled at first.

As I’m unsure exactly what you have done up to now I’ll do my best in describing the issues I faced.

My issue was due to two reasons:

1) I had used Google API’s before for other things and I added my connection to a pre-existing project which messed things up. I then created a new one with just my OpenHAB connection in. Go to https://console.developers.google.com below is what you should have.


.
.
When created correctly you will see it on it’s own and select it from the top left like below:
2018-03-10%2008_27_16-Dashboard%20-%20openHAB
.
.

2) Something else I had not done was “Enable the API” for the Google Calendar.

Click Dashboard then “ENABLE APIS AND SERVICES AS BELOW”:


.
.
Search for it:

.
.
Enable it:

Once this is done:

  1. Delete the token as mentioned above and restart the bundle

  2. Check the log as before for the integration instructions. Follow them and hopefully it works.

1 Like

Thank you very much! Finally it is working!
Thanks for the detailed tutorial!

No problem, pleased you got it working :+1:

First, you should have started a new thread for this (which I still suggest).
Second, you didn’t include anything for anyone to try to help you (e.g. logs, settings, OS, etc.)

New Topic on this binding