Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'albums' of null #11

Open
janvda opened this issue Dec 15, 2019 · 7 comments
Open

TypeError: Cannot read property 'albums' of null #11

janvda opened this issue Dec 15, 2019 · 7 comments

Comments

@janvda
Copy link
Owner

janvda commented Dec 15, 2019

The following is logged:

15.12.19 15:02:08 (+0100)  node-red  15 Dec 14:02:08 - [warn] [google:google photos api] node.on('input'):[object Object]
15.12.19 15:02:08 (+0100)  node-red  15 Dec 14:02:08 - [warn] [google:google photos api] get_albums_list ...
15.12.19 15:02:08 (+0100)  node-red  15 Dec 14:02:08 - [error] [google:google photos api] TypeError: Cannot read property 'albums' of null
15.12.19 15:02:08 (+0100)  node-red  15 Dec 14:02:08 - [warn] [google:google photos api] ... end node.on()
@janvda
Copy link
Owner Author

janvda commented Dec 15, 2019

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.

@janvda
Copy link
Owner Author

janvda commented Dec 15, 2019

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"}}

@janvda
Copy link
Owner Author

janvda commented Dec 15, 2019

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.

@janvda
Copy link
Owner Author

janvda commented Dec 15, 2019

npm install --save-exact google-auth-library@5.6.1

@janvda
Copy link
Owner Author

janvda commented Dec 16, 2019

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

@janvda
Copy link
Owner Author

janvda commented Dec 16, 2019

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$ 

@janvda
Copy link
Owner Author

janvda commented Dec 16, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant