"Invalid credentials" when using my own Google cloud function for ES
Posted: Sat Sep 04, 2021 1:02 pm
Hi asker and everyone,
My system is Zoneminder 1.32.3, ES version 6.1.27, zmNinja 1.6.009. Everything works perfectly with the current FCMV1 link 'https://us-central1-ninja-1105.cloudfun ... /send_push'.
This is the debug log I got when using the current FCMV1 link:
FORK:Floor1 (4), eid:298774 fcmv1: Final JSON using FCMV1 being sent is: {"token":"fBJFbUdSToaEUVlRUvddlw:APA91bEWItPBz67gDP1Ra7pb2578zGt5tvVf1KwotcZ0jEmCzH4f_flq3_HUVCnvQ3S0LqfxYakxRIsVzOjX4JgsyvdM6DCQwO8E6mao1BbvDCkl9Jh_eEA6sVDM3ZXPBrREoI1fvMRF","android":{"priority":"high","channel":"zmninja","icon":"ic_stat_notification"},"title":"Floor1 Alarm (298774)","data":{"notification_foreground":"true","eid":"298774","mid":"4"},"image_url":"https://localhost/zm/index.php?view=ima ... ssword=xxx} to token: ...1fvMRF
DBG-1:2021-08-29,19:11:14 |----> FORK:Floor1 (4), eid:298774 fcmv1: FCM push message returned a 200 with body {"Success":"projects/ninja-1105/messages/0:1630239073797130%311426be311426be"}
I followed the instructions to set up Google cloud function (https://medium.com/zmninja/using-your-o ... 8897d0ff49). I kept the code intact and changed only the fcm_v1_url to my new 'Trusted App' via URL 'https://us-central1-zmninjatest.cloudfu ... send_pusha' and I could get new notifications on my Android phone. However I got this in the log "Invalid credentials: Signature verification failed" although I keep intact “<YOUR_SECRET_HERE>” and DEFAULT_FCM_V1_KEY in zmeventnotification.pl and zmeventnotification.ini. If I restart my PC then I could not receive notifications on my phone anymore. If I use the FCMV1 link 'https://us-central1-ninja-1105.cloudfun ... /send_push', everything works normal again.
I tried to set up OAuth consent screen for my 'Trust App' in APIs & Services in my Google Cloud Platform and used a new token in fcm_v1_key but I still get "Invalid credentials" in the debug log although I still get notifications on my phone.
Could you please help me to resolve this problem? Many thanks in advance.
Regards,
Hieu
Here is the debug log I got when I use my new Google cloud function URL. I still receive notifications on my Android phone if I do not restart the PC.
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 rules: Checking rules for alarm caused by eid:309412, monitor:3, at: Fri Sep 3 18:30:06 2021 with cause:[s] detected:person:99% Motion All
DBG-1:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 rules: No rules found for Monitor, allowing:3
DBG-1:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 Matching alarm to connection rules...
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 isAllowedChannel: got type:event_end resCode:0
INF:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 Sending event_end notification over FCM
03/09/2021 18:30:06.713976 zmeventnotification[11695].INF [main:1049] [|----> FORK:Tum (3), eid:309412 Sending event_end notification over FCM]
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 fcmv1: Snapshot frame matched, changing picture url to:https://localhost/zm/index.php?view=ima ... d=1Wax2qsz
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 setting channel to zmninja
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 fcmv1: Final JSON using FCMV1 being sent is: {"badge":2,"log_message_id":"NONE","data":{"notification_foreground":"true","mid":"3","eid":"309412"},"android":{"priority":"high","channel":"zmninja","icon":"ic_stat_notification"},"image_url":"https://localhost/zm/index.php?view=ima ... ssword=xxx} to token: ...1fvMRF
DBG-1:2021-09-03,18:30:07 |----> FORK:Tum (3), eid:309412 fcmv1: FCM push message error {"Error":"Invalid credentials: Signature verification failed"}
DBG-2:2021-09-03,18:30:07 |----> FORK:Tum (3), eid:309412 child finished writing to parent
DBG-2:2021-09-03,18:30:10 PARENT: ----------> Tick START (active forks:2, total forks:4, active hooks: 1 running for:6 min)<--------------
DBG-2:2021-09-03,18:30:10 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-09-03,18:30:10 PARENT: RAW TEXT-->fcm_notification--TYPE--fBJFbUdSToaEUVlRUvddlw:APA91bEWItPBz67gDP1Ra7pb2578zGt5tvVf1KwotcZ0jEmCzH4f_flq3_HUVCnvQ3S0LqfxYakxRIsVzOjX4JgsyvdM6DCQwO8E6mao1BbvDCkl9Jh_eEA6sVDM3ZXPBrREoI1fvMRF--SPLIT--2--SPLIT--736--SPLIT--8
DBG-2:2021-09-03,18:30:10 PARENT: GOT JOB==> update badge to 2, count to 736 for: fBJFbUdSToaEUVlRUvddlw:APA91bEWItPBz67gDP1Ra7pb2578zGt5tvVf1KwotcZ0jEmCzH4f_flq3_HUVCnvQ3S0LqfxYakxRIsVzOjX4JgsyvdM6DCQwO8E6mao1BbvDCkl9Jh_eEA6sVDM3ZXPBrREoI1fvMRF, at: 8
DBG-2:2021-09-03,18:30:10 PARENT: RAW TEXT-->timestamp--TYPE--1630668265.65701--SPLIT--3--SPLIT--1630668606.71364
DBG-2:2021-09-03,18:30:10 PARENT: Job: Update last sent timestamp of monitor:3 to 1630668606.71364 for id:1630668265.65701
DBG-2:2021-09-03,18:30:10 PARENT: There are 2 active child forks & 1 zm_detect processes running...
DBG-2:2021-09-03,18:30:10 PARENT: checkEvents() new events found=0
DBG-2:2021-09-03,18:30:10 PARENT: There are 0 new Events to process
DBG-2:2021-09-03,18:30:10 PARENT: ---------->Tick END (active forks:2, total forks:4, active hooks: 1)<--------------
DBG-1:2021-09-03,18:30:11 |----> FORK:Tum (3), eid:309412 exiting
DBG-1:2021-09-03,18:30:11 |----> FORK:Tum (3), eid:309412 Ending process:11695 to handle alarms
DBG-2:2021-09-03,18:30:15 PARENT: ----------> Tick START (active forks:2, total forks:4, active hooks: 1 running for:6 min)<--------------
DBG-2:2021-09-03,18:30:15 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-09-03,18:30:15 PARENT: RAW TEXT-->active_event_delete--TYPE--3--SPLIT--309412
DBG-2:2021-09-03,18:30:15 PARENT: Job: Deleting active_event eid:309412, mid:3
DBG-2:2021-09-03,18:30:15 PARENT: There are 1 active child forks & 1 zm_detect processes running...
DBG-2:2021-09-03,18:30:15 PARENT: checkEvents() new events found=0
DBG-2:2021-09-03,18:30:15 PARENT: There are 0 new Events to process
DBG-2:2021-09-03,18:30:15 PARENT: ---------->Tick END (active forks:1, total forks:4, active hooks: 1)<--------------
DBG-2:2021-09-03,18:30:20 PARENT: ----------> Tick START (active forks:1, total forks:4, active hooks: 1 running for:6 min)<--------------
DBG-2:2021-09-03,18:30:20 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-09-03,18:30:20 PARENT: There are 1 active child forks & 1 zm_detect processes running...
DBG-2:2021-09-03,18:30:20 PARENT: checkEvents() new events found=0
DBG-2:2021-09-03,18:30:20 PARENT: There are 0 new Events to process
DBG-2:2021-09-03,18:30:20 PARENT: ---------->Tick END (active forks:1, total forks:4, active hooks: 1)<--------------
DBG-2:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 parse of hook:[a] detected:person:83% and {"labels": ["person"], "boxes": [[430, 352, 772, 596]], "frame_id": "alarm", "confidences": [0.8271722197532654], "image_dimensions": {"original": [480, 640], "resized": [600, 800]}}
DBG-1:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 hook start returned with text:[a] detected:person:83% json:{"labels": ["person"], "boxes": [[430, 352, 772, 596]], "frame_id": "alarm", "confidences": [0.8271722197532654], "image_dimensions": {"original": [480, 640], "resized": [600, 800]}} exit:0
DBG-2:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 For 3 (Tum), SHM says: state=0, eid=309416
INF:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 Event 309414 for Monitor 3 has finished
03/09/2021 18:30:24.500391 zmeventnotification[12057].INF [main:1049] [|----> FORK:Tum (3), eid:309414 Event 309414 for Monitor 3 has finished]
DBG-2:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 Event end object is: state=>pending with cause=>[a] detected:person:83% Motion: All [a] detected:person:83% Motion: All
DBG-2:2021-09-03,18:30:25 PARENT: ----------> Tick START (active forks:1, total forks:4, active hooks: 1 running for:7 min)<--------------
DBG-2:2021-09-03,18:30:25 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
My system is Zoneminder 1.32.3, ES version 6.1.27, zmNinja 1.6.009. Everything works perfectly with the current FCMV1 link 'https://us-central1-ninja-1105.cloudfun ... /send_push'.
This is the debug log I got when using the current FCMV1 link:
FORK:Floor1 (4), eid:298774 fcmv1: Final JSON using FCMV1 being sent is: {"token":"fBJFbUdSToaEUVlRUvddlw:APA91bEWItPBz67gDP1Ra7pb2578zGt5tvVf1KwotcZ0jEmCzH4f_flq3_HUVCnvQ3S0LqfxYakxRIsVzOjX4JgsyvdM6DCQwO8E6mao1BbvDCkl9Jh_eEA6sVDM3ZXPBrREoI1fvMRF","android":{"priority":"high","channel":"zmninja","icon":"ic_stat_notification"},"title":"Floor1 Alarm (298774)","data":{"notification_foreground":"true","eid":"298774","mid":"4"},"image_url":"https://localhost/zm/index.php?view=ima ... ssword=xxx} to token: ...1fvMRF
DBG-1:2021-08-29,19:11:14 |----> FORK:Floor1 (4), eid:298774 fcmv1: FCM push message returned a 200 with body {"Success":"projects/ninja-1105/messages/0:1630239073797130%311426be311426be"}
I followed the instructions to set up Google cloud function (https://medium.com/zmninja/using-your-o ... 8897d0ff49). I kept the code intact and changed only the fcm_v1_url to my new 'Trusted App' via URL 'https://us-central1-zmninjatest.cloudfu ... send_pusha' and I could get new notifications on my Android phone. However I got this in the log "Invalid credentials: Signature verification failed" although I keep intact “<YOUR_SECRET_HERE>” and DEFAULT_FCM_V1_KEY in zmeventnotification.pl and zmeventnotification.ini. If I restart my PC then I could not receive notifications on my phone anymore. If I use the FCMV1 link 'https://us-central1-ninja-1105.cloudfun ... /send_push', everything works normal again.
I tried to set up OAuth consent screen for my 'Trust App' in APIs & Services in my Google Cloud Platform and used a new token in fcm_v1_key but I still get "Invalid credentials" in the debug log although I still get notifications on my phone.
Could you please help me to resolve this problem? Many thanks in advance.
Regards,
Hieu
Here is the debug log I got when I use my new Google cloud function URL. I still receive notifications on my Android phone if I do not restart the PC.
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 rules: Checking rules for alarm caused by eid:309412, monitor:3, at: Fri Sep 3 18:30:06 2021 with cause:[s] detected:person:99% Motion All
DBG-1:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 rules: No rules found for Monitor, allowing:3
DBG-1:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 Matching alarm to connection rules...
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 isAllowedChannel: got type:event_end resCode:0
INF:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 Sending event_end notification over FCM
03/09/2021 18:30:06.713976 zmeventnotification[11695].INF [main:1049] [|----> FORK:Tum (3), eid:309412 Sending event_end notification over FCM]
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 fcmv1: Snapshot frame matched, changing picture url to:https://localhost/zm/index.php?view=ima ... d=1Wax2qsz
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 setting channel to zmninja
DBG-2:2021-09-03,18:30:06 |----> FORK:Tum (3), eid:309412 fcmv1: Final JSON using FCMV1 being sent is: {"badge":2,"log_message_id":"NONE","data":{"notification_foreground":"true","mid":"3","eid":"309412"},"android":{"priority":"high","channel":"zmninja","icon":"ic_stat_notification"},"image_url":"https://localhost/zm/index.php?view=ima ... ssword=xxx} to token: ...1fvMRF
DBG-1:2021-09-03,18:30:07 |----> FORK:Tum (3), eid:309412 fcmv1: FCM push message error {"Error":"Invalid credentials: Signature verification failed"}
DBG-2:2021-09-03,18:30:07 |----> FORK:Tum (3), eid:309412 child finished writing to parent
DBG-2:2021-09-03,18:30:10 PARENT: ----------> Tick START (active forks:2, total forks:4, active hooks: 1 running for:6 min)<--------------
DBG-2:2021-09-03,18:30:10 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-09-03,18:30:10 PARENT: RAW TEXT-->fcm_notification--TYPE--fBJFbUdSToaEUVlRUvddlw:APA91bEWItPBz67gDP1Ra7pb2578zGt5tvVf1KwotcZ0jEmCzH4f_flq3_HUVCnvQ3S0LqfxYakxRIsVzOjX4JgsyvdM6DCQwO8E6mao1BbvDCkl9Jh_eEA6sVDM3ZXPBrREoI1fvMRF--SPLIT--2--SPLIT--736--SPLIT--8
DBG-2:2021-09-03,18:30:10 PARENT: GOT JOB==> update badge to 2, count to 736 for: fBJFbUdSToaEUVlRUvddlw:APA91bEWItPBz67gDP1Ra7pb2578zGt5tvVf1KwotcZ0jEmCzH4f_flq3_HUVCnvQ3S0LqfxYakxRIsVzOjX4JgsyvdM6DCQwO8E6mao1BbvDCkl9Jh_eEA6sVDM3ZXPBrREoI1fvMRF, at: 8
DBG-2:2021-09-03,18:30:10 PARENT: RAW TEXT-->timestamp--TYPE--1630668265.65701--SPLIT--3--SPLIT--1630668606.71364
DBG-2:2021-09-03,18:30:10 PARENT: Job: Update last sent timestamp of monitor:3 to 1630668606.71364 for id:1630668265.65701
DBG-2:2021-09-03,18:30:10 PARENT: There are 2 active child forks & 1 zm_detect processes running...
DBG-2:2021-09-03,18:30:10 PARENT: checkEvents() new events found=0
DBG-2:2021-09-03,18:30:10 PARENT: There are 0 new Events to process
DBG-2:2021-09-03,18:30:10 PARENT: ---------->Tick END (active forks:2, total forks:4, active hooks: 1)<--------------
DBG-1:2021-09-03,18:30:11 |----> FORK:Tum (3), eid:309412 exiting
DBG-1:2021-09-03,18:30:11 |----> FORK:Tum (3), eid:309412 Ending process:11695 to handle alarms
DBG-2:2021-09-03,18:30:15 PARENT: ----------> Tick START (active forks:2, total forks:4, active hooks: 1 running for:6 min)<--------------
DBG-2:2021-09-03,18:30:15 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-09-03,18:30:15 PARENT: RAW TEXT-->active_event_delete--TYPE--3--SPLIT--309412
DBG-2:2021-09-03,18:30:15 PARENT: Job: Deleting active_event eid:309412, mid:3
DBG-2:2021-09-03,18:30:15 PARENT: There are 1 active child forks & 1 zm_detect processes running...
DBG-2:2021-09-03,18:30:15 PARENT: checkEvents() new events found=0
DBG-2:2021-09-03,18:30:15 PARENT: There are 0 new Events to process
DBG-2:2021-09-03,18:30:15 PARENT: ---------->Tick END (active forks:1, total forks:4, active hooks: 1)<--------------
DBG-2:2021-09-03,18:30:20 PARENT: ----------> Tick START (active forks:1, total forks:4, active hooks: 1 running for:6 min)<--------------
DBG-2:2021-09-03,18:30:20 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-09-03,18:30:20 PARENT: There are 1 active child forks & 1 zm_detect processes running...
DBG-2:2021-09-03,18:30:20 PARENT: checkEvents() new events found=0
DBG-2:2021-09-03,18:30:20 PARENT: There are 0 new Events to process
DBG-2:2021-09-03,18:30:20 PARENT: ---------->Tick END (active forks:1, total forks:4, active hooks: 1)<--------------
DBG-2:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 parse of hook:[a] detected:person:83% and {"labels": ["person"], "boxes": [[430, 352, 772, 596]], "frame_id": "alarm", "confidences": [0.8271722197532654], "image_dimensions": {"original": [480, 640], "resized": [600, 800]}}
DBG-1:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 hook start returned with text:[a] detected:person:83% json:{"labels": ["person"], "boxes": [[430, 352, 772, 596]], "frame_id": "alarm", "confidences": [0.8271722197532654], "image_dimensions": {"original": [480, 640], "resized": [600, 800]}} exit:0
DBG-2:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 For 3 (Tum), SHM says: state=0, eid=309416
INF:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 Event 309414 for Monitor 3 has finished
03/09/2021 18:30:24.500391 zmeventnotification[12057].INF [main:1049] [|----> FORK:Tum (3), eid:309414 Event 309414 for Monitor 3 has finished]
DBG-2:2021-09-03,18:30:24 |----> FORK:Tum (3), eid:309414 Event end object is: state=>pending with cause=>[a] detected:person:83% Motion: All [a] detected:person:83% Motion: All
DBG-2:2021-09-03,18:30:25 PARENT: ----------> Tick START (active forks:1, total forks:4, active hooks: 1 running for:7 min)<--------------
DBG-2:2021-09-03,18:30:25 PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0