hermanho / MMM-GooglePhotos

Display your photos on MagicMirror from Google Photos.
MIT License
170 stars 65 forks source link

auth_and_test.js starts, but no album ids are pulled #21

Closed gregscottirwin closed 5 years ago

gregscottirwin commented 5 years ago

I'm guessing this is a user error, but I cannot figure out how or why. I go through all of the steps to install MMM-GooglePhotos on MagicMirror. Everything goes exactly according to the directions until I get to running auth_and_test.js. I run "node auth_and_test.js" from /MagicMirror/modules/MMM-GooglePhotos $. When I do this, I see "auth_and_test started". Then the console just hangs. No more output occurs and I so I can't find my Google Photo album ids to continue through the setup.

Then if I close out of the terminal, reopen terminal and try to run the command again, it shows "auth_and_test started" and then returns to the $ prompt.

Needless to say I'm stuck and not sure where to go from here. Any help would be greatly appreciated. Thank you in advance.

Raspberry Pi 3 Model B v1.2 Raspbian v 9.9 MagicMirror v2.7.1 node.js 10.16.0

eouia commented 5 years ago

Do you have credentials.json in your module directory rightly?

gregscottirwin commented 5 years ago

I do. I downloaded the json file from google photos, changed the name to "credentials.json", and then moved it into the folder "MMM-GooglePhotos" under the 'modules' directory.

eouia commented 5 years ago

Check one more thing. Is there token.json in your module directory? If there is, remove it and try node auth_and_test.js again.

gregscottirwin commented 5 years ago

The token.json file is only in the /MagicMirror/modules/MMM-GooglePhotos directory. There is not a separate token.json in the /MagicMirror/modules/ directory. Do you mean take it out of the MMM-GooglePhotos directory?

the only things I have in the modules directory are default, MMM-GooglePhotos, and node_modules folders.

I appreciate your help. I'm wondering if it might be something in my Google OAuth settings, but I followed your directions, so i'm not sure.

eouia commented 5 years ago

I meant MMM-GooglePhotos directory. If the token.json was corrupted, your symptom could be happened. I doubt your token was expired. In the module, it will be refreshed automatically, but in the first auth step, I didn't put the refreshing process in auth_and_test.js. However, sometimes ppl fails to get auth rightly, so token might have been out-of-dated. Anyway, remove token.json and retry again. You might be requested to allow in a browser.

gregscottirwin commented 5 years ago

I removed the token and the same result happened where it took me to the website to auth, asks me to Paste my code, then outputs: auth_and_test started. The the terminal hangs with no further output and it does not return to the $ prompt.

One additional piece of info - when the process takes me to the auth step, it does ask to trust the developer and I have to click through an additional screen to an "unsecure" site and process. I wouldn't think that had anything to do with it, but wanted to add it in case there was something to that.

Let me know what other information I can provide to help us troubleshoot this together. I'm interested in learning as well as getting this fixed.

Thanks so much @eouia

eouia commented 5 years ago

So you couldn't get and paste code to prompt? In that case, your browser might have some issue about managing cache. Clearing cache and retry, or.... Just copy the URL and open it on another browser.

gregscottirwin commented 5 years ago

i'm sorry - I don't think my last post was clear. I was able to get to the code to copy and past into the terminal. It is after doing that where the terminal posts auth_and_test started. Then the terminal hangs.

The addition of the 'unsecured' piece I don't think has anything to do with the hang up. So I think we can forget about that. Sorry about the confusion. But I will still clear my cache and try again just to be on the safe side and report back to be sure.

gregscottirwin commented 5 years ago

Same result after clearing the browser cache.

eouia commented 5 years ago

Hmmm.. Check other things;

1) Of course, you have albums and pics in that account. right? (sounds somehow ridiculous.. but) 2) At least one of your albums is your own album, not shared from others. right?

eouia commented 5 years ago

Open auth_and_test.js in Editor, then modify to check somethings.

https://github.com/eouia/MMM-GooglePhotos/blob/6acc084d30f06b2200fa5ba459ff2a3c6cbd3fbc/auth_and_test.js#L36

to

        var found = 0
        console.log("Albums Found:", found)

It will show how many albums in your account. but it cannot reach to shared albums. Accessing shared album is not allowed in SDK level.

gregscottirwin commented 5 years ago

OK well that's a good trick. So now we know the problem. 'Albums Found: 0' So I do have pictures in the account and I believe I own the album called MagicMirror given that I specifically created it under the google account for the purpose of this project. And I selected photos to go into that album.

So your code is great, as I figured! And it somehow seems to be user error. But I can't figure that part out either though.

Any thoughts or should I go investigating elsewhere?

Thanks again for all of your help @eouia.

gregscottirwin commented 5 years ago

Question - should the auth code that comes up when I run auth_and_test.js be found in the 'token.json' file? Or do you encode it with SHA or something like that?

Is there a way to check if the connection is even happening to the right account? I don't know how it wouldn't be, but just a thought.

gregscottirwin commented 5 years ago

Nevermind - ugh. Sorry to waste your time @eouia

This is part of why I hate (and love) google all at the same time.

Somehow (even though I was logged in under the right account), the Photos API had been activated for my "default" google account instead of the one I wanted. Definitely User Error.

I am terribly sorry to bother you, however you did help immensely and I couldn't have gotten to this point without your help! Thank you again!