gilesknap / gphotos-sync

Google Photos and Albums backup with Google Photos Library API
Apache License 2.0
1.97k stars 161 forks source link

Unable to connect to my google account #415

Closed bejibe closed 1 year ago

bejibe commented 1 year ago

Dear Gilesknap, After reaching the last screen copy of your page https://gilesknap.github.io/gphotos-sync/main/tutorials/login.html I.e. "The next screen shows you the permissions you may grant to this application. Tick all the boxes and click ‘Continue’. The command line gphotos-sync will then continue to run and start to backup the user’s library." I click on CONTINUE and get the message from a localhost url: "Connection failed Firefox can not establish a connection with the server at localhost. etc..." How to overpass this step?

gilesknap commented 1 year ago

So localhost address means your browser and gphotos-sync need to run on the same machine.

If you are running in a container or on a server then please see https://gilesknap.github.io/gphotos-sync/main/tutorials/installation.html#headless-gphotos-sync-servers

if you are running locally then it could be a firewall issue.

bejibe commented 1 year ago

Thanks for the answer. I stopped the firewall when proceeding the connection with Firefox browser. Unfortunately ; Same result. I am not running in a container nor on a server. Running on a PC with ubuntu. Rem: I can use google photo and any google tool in the browser. the URL Firefox doesn't manage to open is ; http://localhost/?state=vdr2<< REDACTED >>hea-f-Ns9w&scope=https://www.googleapis.com/auth/photoslibrary.sharing%20https://www.googleapis.com/auth/photoslibrary.readonly

gilesknap commented 1 year ago

I've had a few reports like this recently. I'm going to do some work on gphotos-sync this weekend and test the flow again. It's possible that there has been a change to the Google API (not very likely) and they have released 1.0.0 of the auth library we use so I'll be upgrading to that.

I'll report back on any findings here.

gilesknap commented 1 year ago

I'm updating the google api libraries today. reviewing your issue I note that there is something wrong with the URL you posted. It is using the default port 80.

It should be using 8080 or the port that you specify in --port

Mine looks like this:

http://localhost:8080/?state=MnMP<< REDACTED >> tqEDvrw&scope=https://www.googleapis.com/auth/photoslibrary.readonly%20https://www.googleapis.com/auth/photoslibrary.sharing

Please try passing a port number e.g. --port 8090 and post your URL again. (you should REDACT the keys it passes)

bejibe commented 1 year ago

Dear Gilesknap, thanks for your efforts. I tried with port 8080, both with active and inactive firewall. Still same message. What I do not get from your note is "... the port you specify in --port" : I do not remember a place where I am able to specify a port in the Google Cloud API Photos Library manager. Which specification feature I are you refering to, please ? Can't it be a feature in my local ubuntu PC that has not been activated, such as a local web service? (I am beginer so I don't know if such service is activated by default when installing a new PC) regards

gilesknap commented 1 year ago

Hi @bejibe

What I mean is to pass --port 8090 to gphotos-sync command line. If you try gphotos-sync --help you will see the full list of options.

When you posted the URL here https://github.com/gilesknap/gphotos-sync/issues/415#issuecomment-1460839350 it was http://localhost/?state= ... But it should be http:8080://localhost/?state= ... The 8080 is the port that the browser is being asked to connect to. The localhost:8080 directs your browser back to a web server that is running inside of the gphotos process itself.

By example - the command:

gphotos-sync --port 8888 /tmp/test-photos

results in:

03-12 19:44:30 WARNING  gphotos-sync 3.1.0 2023-03-12 19:44:30.246037 
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=108XXXXXX685-4fjqfnxxxxxxxxxxxxxxxxxxft3.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8888%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.readonly+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.sharing&state=zA1deXXXXXXXXXXXXX5b94JT&access_type=offline
03-12 19:44:44 WARNING  Indexing Google Photos Files ... 

In the above I specified port 8888 and you can see the redirect_uri which is what the browser will be redirected back to on completion of the authetication flow also contains 8888:

redirect_uri=http%3A%2F%2Flocalhost%3A8888

meaning the final URL that tries to connect back to gphotos-sync should look like:

http://localhost:8888/?state= ...
gilesknap commented 1 year ago

@bejibe any luck with the above?

bejibe commented 1 year ago

Sorry for late feedback, I had not seen your last post. Since my "manual" test writing :8080 in the url was giving the same result, I resolved reinstalling Ubuntu 22.04 Took time this weekend and I have not yet finished reinstalling all snaps. Will do gphotos-sync next week end I hope. I shall keep you posted.

gilesknap commented 1 year ago

@bejibe let me know how you got on with this. Please close if the reinstall resolved the issue.

kvietcong commented 1 year ago

Hi, ran into a very similar issue where I was getting a 404 after giving auth permissions. However, the suggestion by @gilesknap to change the port to 8090 worked out for me and it allowed the program to continue. Thanks!

gilesknap commented 1 year ago

OK closing as resolved for the moment. @bejibe please re-open if needed.