mtalcott / google-photos-deduper

Locally run web app and Chrome extension to remove duplicates from Google Photos
MIT License
139 stars 11 forks source link

403 Client Error: Forbidden for url: https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=100 #44

Open 3choBoomer opened 4 months ago

3choBoomer commented 4 months ago

I have doublechecked the scopes, the client secret and the client id.

image

When I click start on the Select Options page, I get the following on the screen:

image

and the following in the console logs:

google-photos-deduper-worker-1  | [2024-03-13 13:40:42,302: ERROR/ForkPoolWorker-31] Task app.tasks.process_duplicates[09d00cc7-3f48-4930-a4c5-523cebc4a9d9] raised unexpected: HTTPError('403 Client Error: Forbidden for url: https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=100')
google-photos-deduper-worker-1  | Traceback (most recent call last):
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 477, in trace_task
google-photos-deduper-worker-1  |     R = retval = fun(*args, **kwargs)
google-photos-deduper-worker-1  |   File "/usr/src/app/app/__init__.py", line 25, in __call__
google-photos-deduper-worker-1  |     return self.run(*args, **kwargs)
google-photos-deduper-worker-1  |   File "/usr/src/app/app/tasks.py", line 111, in process_duplicates
google-photos-deduper-worker-1  |     results = task_instance.run()
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/process_duplicates_task.py", line 91, in run
google-photos-deduper-worker-1  |     self._fetch_media_items(client)
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/process_duplicates_task.py", line 196, in _fetch_media_items
google-photos-deduper-worker-1  |     client.fetch_media_items(callback=fetch_callback)
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/google_photos_client.py", line 44, in fetch_media_items
google-photos-deduper-worker-1  |     resp_json = self._refresh_credentials_if_invalid(func)
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/google_api_client.py", line 131, in _refresh_credentials_if_invalid
google-photos-deduper-worker-1  |     raise error
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/google_api_client.py", line 124, in _refresh_credentials_if_invalid
google-photos-deduper-worker-1  |     return func()
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/google_photos_client.py", line 39, in func
google-photos-deduper-worker-1  |     return self.session.get(
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 602, in get
google-photos-deduper-worker-1  |     return self.request("GET", url, **kwargs)
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/google/auth/transport/requests.py", line 549, in request
google-photos-deduper-worker-1  |     response = super(AuthorizedSession, self).request(
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
google-photos-deduper-worker-1  |     resp = self.send(prep, **send_kwargs)
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 710, in send
google-photos-deduper-worker-1  |     r = dispatch_hook("response", hooks, r, **kwargs)
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/requests/hooks.py", line 30, in dispatch_hook
google-photos-deduper-worker-1  |     _hook_data = hook(hook_data, **kwargs)
google-photos-deduper-worker-1  |   File "/usr/src/app/app/lib/google_api_client.py", line 141, in <lambda>
google-photos-deduper-worker-1  |     session.hooks = {"response": lambda r, *args, **kwargs: r.raise_for_status()}
google-photos-deduper-worker-1  |   File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
google-photos-deduper-worker-1  |     raise HTTPError(http_error_msg, response=self)
google-photos-deduper-worker-1  | requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=100
mtalcott commented 1 month ago

I would expect this kind of error if something about the OAuth credentials or project permissions were off. Could you try running through step 3 of the setup instructions again (Create a Google Cloud project and OAuth credentials) with a new Google Cloud project?

moaz-ahmed commented 1 week ago

In the Enable APIs & Services search for Photos Library API and make sure it's enabled for your project. That fixed it for me! image