Hi
I installed and prepared Gcal3 exactly as in your documentation. But now then I’m moving device in Armed state, error 400 appears
Exact text:
token error code: HTTP/1.0 400 Bad Request
Fatal Calendar Error
Found this text in GCal3.lua and added some debug info. So there is log output:
50 01/16/19 20:10:35.775 luup_log:83: GCal3 device: 8383 - Checking for access-token <0x7624f520>
50 01/16/19 20:10:35.775 luup_log:83: GCal3 device: 8383 - local function: get_access_token <0x7624f520>
50 01/16/19 20:10:35.776 luup_log:83: GCal3 device: 8383 - Getting a new token <0x7624f520>
50 01/16/19 20:10:35.776 luup_log:83: GCal3 device: 8383 - local function: os_command <0x7624f520>
50 01/16/19 20:10:35.777 luup_log:83: GCal3 device: 8383 - Command was: echo -n ‘{“iss":"gcal3-for-friday@gcal3-228616.iam.gserviceaccount.com”,“scope”:“https://www.googleapis.com/auth/calendar",“aud”:“https://accounts.google.com/o/oauth2/token”,"exp”:1547662235, “iat”:1547658635}’ | openssl base64 -e <0x7624f520>
50 01/16/19 20:10:35.799 luup_log:83: GCal3 device: 8383 - local function: os_command <0x7624f520>
50 01/16/19 20:10:35.800 luup_log:83: GCal3 device: 8383 - Command was: echo -n hidden | openssl dgst -sha256 -sign /etc/cmh-ludl/GCal3/GCal3cred.pem | openssl base64 -e <0x7624f520>
50 01/16/19 20:10:35.830 luup_log:83: GCal3 device: 8383 - post request for token: grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=hidden <0x7624f520> ← log added by me
50 01/16/19 20:10:35.999 luup_log:83: GCal3 device: 8383 - https token code: 400 <0x7624f520>
50 01/16/19 20:10:36.000 luup_log:83: GCal3 device: 8383 - https token status: HTTP/1.0 400 Bad Request <0x7624f520>
50 01/16/19 20:10:36.000 luup_log:83: GCal3 device: 8383 - token error code: HTTP/1.0 400 Bad Request <0x7624f520>
06 01/16/19 20:10:36.001 Device_Variable::m_szValue_set device: 83 service: urn:srs-com:serviceId:GCalIII variable: e[35;1mgc_NextEvente[0m was: CalendarID is set now: token error code: HTTP/1.0 400 Bad Request #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x7624f520>
06 01/16/19 20:10:36.003 Device_Variable::m_szValue_set device: 83 service: urn:srs-com:serviceId:GCalIII variable: e[35;1mgc_NextEventTimee[0m was: Credentials File Set now: #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x7624f520>
50 01/16/19 20:10:36.004 luup_log:83: GCal3 device: 8383 - GC.access_token is: false <0x7624f520>
50 01/16/19 20:10:36.005 luup_log:83: GCal3 device: 8383 - GCV.CredentialCheck is false <0x7624f520>
May be also helpful:
When I execute same request in Postman I get
Codes in the 400 group generally mean that there is something like a calendar ID /credentials mismatch (i.e. right calendar wrong credentials file or vice-versa) or your settings in the calendar permissions are incorrect.
This code is very stable - so absent a network / connectivity issue with google, you should recheck your settings and the accuracy with which you created the credential file.
First, just in case something crazy is happening, use the test calendar ID and test credentials to eliminate all else.