gilesknap / gphotos-sync

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

Not able to run gphotos-sync #389

Closed Koramchad closed 1 year ago

Koramchad commented 1 year ago

I tried to run gphotos sync one more time on my Qnap to continue making progress on downloading more photos. I got an error on my Qnap, so I tried to get a new .gphotos.token from my Mac to see if that would fix it, but I'm also getting errors on that process.

This is from my Mac:

(gphotos) alvaro@Alvaros-MBP ~ % gphotos-sync --skip-files --skip-albums --skip-index ~/Downloads/gphotos

10-09 13:33:17 WARNING  gphotos-sync 3.0.3 2022-10-09 13:33:17.842900 
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=267860787202-s4432r4q8ot299o1ghp5lc0739drvond.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.readonly+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.sharing&state=ZdtphPwAsDVnejPL1NaNUt7HuCH83D&access_type=offline
10-09 13:33:31 ERROR    
Process failed. 
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gphotos_sync/Main.py", line 496, in main
    self.setup(args, db_path)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gphotos_sync/Main.py", line 345, in setup
    self.auth.authorize()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gphotos_sync/authorize.py", line 96, in authorize
    flow.run_local_server(open_browser=False, host=self.host, port=self.port)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/google_auth_oauthlib/flow.py", line 511, in run_local_server
    self.fetch_token(authorization_response=authorization_response)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/google_auth_oauthlib/flow.py", line 300, in fetch_token
    return self.oauth2session.fetch_token(self.client_config["token_uri"], **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 366, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 427, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response
    validate_token_parameters(params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidClientError: (invalid_client) Unauthorized
10-09 13:33:31 WARNING  Done. 

I get tho the login on the browser and I get a successfull message, but the terminal gives me the error above.

This is the error I got on my Qnap when I tried to run gphotos-sync after it worked last time:

[/share/Container/photoprism] # gphotos-sync /share/Photos 10-09 13:02:03 WARNING gphotos-sync 3.0.3 2022-10-09 13:02:03.956829 10-09 13:02:03 ERROR Process failed. Traceback (most recent call last): File "/opt/lib/python3.10/site-packages/gphotos_sync/Main.py", line 496, in main self.setup(args, db_path) File "/opt/lib/python3.10/site-packages/gphotos_sync/Main.py", line 345, in setup self.auth.authorize() File "/opt/lib/python3.10/site-packages/gphotos_sync/authorize.py", line 96, in authorize flow.run_local_server(open_browser=False, host=self.host, port=self.port) File "/opt/lib/python3.10/site-packages/google_auth_oauthlib/flow.py", line 491, in run_local_server local_server = wsgiref.simple_server.make_server( File "/opt/lib/python3.10/wsgiref/simple_server.py", line 154, in make_server File "/opt/lib/python3.10/socketserver.py", line 452, in __init__ File "/opt/lib/python3.10/wsgiref/simple_server.py", line 50, in server_bind File "/opt/lib/python3.10/http/server.py", line 136, in server_bind File "/opt/lib/python3.10/socketserver.py", line 466, in server_bind OSError: [Errno 98] Address already in use 10-09 13:02:03 WARNING Done.

I did some research on previous issues and found that there was some kind of issue with the port being used. If I try to launch it with a random port, I do get the prompt to login on a browser (which I can't do since it's a server with no browser access).

[/share/Container/photoprism] # gphotos-sync --port 8081 /share/Photos 10-09 13:23:44 WARNING gphotos-sync 3.0.3 2022-10-09 13:23:44.702294 Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=267860787202-s4432r4q8ot299o1ghp5lc0739drvond.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8081%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.readonly+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary.sharing&state=Pi7mHVqxkUAx9LLmKJIxcpSO89rWyp&access_type=offline ^C10-09 13:23:47 ERROR User cancelled download 10-09 13:23:47 WARNING Done. [/share/Container/photoprism] #

What am I missing here?

Thanks!

gilesknap commented 1 year ago

Google's old OOB authentication flow has been deprecated so you need to get a new client secret.

In addition the flow is local only so you need to do it on a machine with a browser first and then transfer the .gphotos.token to your QNAP.

Take a look at https://gilesknap.github.io/gphotos-sync/main/tutorials/installation.html#initial-setup and see if that helps.

gilesknap commented 1 year ago

closing as stale