gilesknap / gphotos-sync

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

Can't get usable token #396

Closed Iceman248 closed 1 year ago

Iceman248 commented 1 year ago

I installed this app on Windows through Python just to generate a token file, then tried to copy that token and eventually the entire folder, but neither way worked. I just get this error. I had read that someone used Python to generate, thought token was for account so therefore it would work, but apparently not. How can I get this going on unRAID? Before, it would just end up at some locahost server in the browser, but I never saw a token generated, so that is why I tried it through Windows.

Request failed with status 401: b'{\n "error": {\n "code": 401,\n "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.",\n "status": "UNAUTHENTICATED"\n }\n}\n' 11-06 15:26:25 ERROR Process failed. Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/gphotos_sync/Main.py", line 497, in main self.start(args) File "/usr/lib/python3.9/site-packages/gphotos_sync/Main.py", line 437, in start self.do_sync(args) File "/usr/lib/python3.9/site-packages/gphotos_sync/Main.py", line 401, in do_sync self.google_photos_idx.index_photos_media() File "/usr/lib/python3.9/site-packages/gphotos_sync/GooglePhotosIndex.py", line 148, in index_photos_media items_json = self.search_media( File "/usr/lib/python3.9/site-packages/gphotos_sync/GooglePhotosIndex.py", line 116, in search_media return self._api.mediaItems.list.execute( # type: ignore File "/usr/lib/python3.9/site-packages/gphotos_sync/restclient.py", line 106, in execute result.raise_for_status() File "/usr/lib/python3.9/site-packages/requests/models.py", line 953, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=100 11-06 15:26:25 WARNING Done.

Iceman248 commented 1 year ago

Regenerating token worked. Hopefully it doesn't have to be done every few hours.

Iceman248 commented 1 year ago

It does have to be done every few hours or so. I don't recall reading anything about that. Is that actually how this works?

I read https://github.com/gilesknap/gphotos-sync/issues/290 and mine already was published, but it still expired very soon.

gilesknap commented 1 year ago

You should never need to regenerate the token, it should be automatically refreshed as needed.

Are you getting the same error above now or do you get 'token expired'?

Iceman248 commented 1 year ago

Well, it just worked this time. Strange. It did appear to regenerate, as the token date is from when I just tried to run it.

I'll monitor and see if it stops working again.