Open janvda opened 4 years ago
Most likely node.photos
is not initialized because the initialization happens in oauth2Client
which is only called when the credentials are expired at the time we call oauth2Client.refreshAccessToken
(which is called at start and every 45 minutes).
So if we keep some patience it might automatically resolve itselves when refreshing the toking after expiration.
When initalizing node.photos = new Photos(node.config.credentials.accessToken);
we know get following error:
15.12.19 16:35:57 (+0100) node-red 15 Dec 15:35:57 - [warn] [google:google photos api] node.on('input'):[object Object]
15.12.19 16:35:57 (+0100) node-red 15 Dec 15:35:57 - [warn] [google:google photos api] get_albums_list ...
15.12.19 16:35:57 (+0100) node-red 15 Dec 15:35:57 - [warn] [google:google photos api] ... end node.on()
15.12.19 16:35:58 (+0100) node-red 15 Dec 15:35:58 - [error] [google:google photos api] StatusCodeError: 401 - {"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}}
I have same problem on macbook installation - so it looks like the google api is recently behaving differently so that tokens are no longer refreshed.
npm install --save-exact google-auth-library@5.6.1
it is working again on macbook although I didn't change anything. macbook has the following configuration:
bash-5.0$ Jans-MBP:~ jan$ npm -v
6.11.3
Welcome to Node-RED
===================
16 Dec 07:46:55 - [info] Node-RED version: v1.0.3
16 Dec 07:46:55 - [info] Node.js version: v10.17.0
16 Dec 07:46:55 - [info] Linux 4.9.184-linuxkit x64 LE
16 Dec 07:46:56 - [info] Loading palette nodes
16 Dec 07:47:04 - [info] Dashboard version 2.19.2 started at /ui
bash-5.0$ npm list | grep google
+-- node-red-contrib-google-photos@0.0.1 -> /data/node-red-contrib-google-photos
| +-- googleapis@45.0.0
| | +-- google-auth-library@5.7.0
| | | | +-- google-p12-pem@2.0.3
| | `-- googleapis-common@3.2.0
| | +-- google-auth-library@5.7.0 deduped
| `-- googlephotos@0.2.5
The configuration of balena having the problem:
16.12.19 08:32:36 (+0100) node-red Welcome to Node-RED
16.12.19 08:32:36 (+0100) node-red ===================
16.12.19 08:32:36 (+0100) node-red
16.12.19 08:32:36 (+0100) node-red 16 Dec 07:32:36 - [info] Node-RED version: v1.0.2
16.12.19 08:32:36 (+0100) node-red 16 Dec 07:32:36 - [info] Node.js version: v12.11.1
16.12.19 08:32:36 (+0100) node-red 16 Dec 07:32:36 - [info] Linux 4.14.98 arm LE
bash-4.4$ npm -v
6.11.3
bash-4.4$ npm list | grep google
+-- google-auth-library@5.6.1
| | +-- google-p12-pem@2.0.3
+-- node-red-contrib-google-photos@0.0.1 (github:janvda/node-red-contrib-google-photos#ad4d710fd3674725c9e45d83fb888db9fcf930e3)
| +-- googleapis@45.0.0
| | +-- google-auth-library@5.6.1 deduped
| | `-- googleapis-common@3.2.0
| | +-- google-auth-library@5.6.1 deduped
| `-- googlephotos@0.2.5
bash-4.4$
installed google-auth-library@5.7.0 on pi3two
bash-4.4$ npm list | grep google
+-- google-auth-library@5.7.0
| | +-- google-p12-pem@2.0.3
+-- node-red-contrib-google-photos@0.0.1 (github:janvda/node-red-contrib-google-photos#ad4d710fd3674725c9e45d83fb888db9fcf930e3)
| +-- googleapis@45.0.0
| | +-- google-auth-library@5.7.0 deduped
| | `-- googleapis-common@3.2.0
| | +-- google-auth-library@5.7.0 deduped
| `-- googlephotos@0.2.5
The following is logged: