nanos / FediFetcher

FediFetcher is a tool for Mastodon that automatically fetches missing replies and posts from other fediverse instances, and adds them to your own Mastodon instance.
https://blog.thms.uk/fedifetcher?utm_source=github
MIT License
310 stars 230 forks source link

FediFetcher fails on checking followings with 401 #117

Closed Sir-Photch closed 3 months ago

Sir-Photch commented 4 months ago

Hi, I'm having this issue where FediFetcher fails fetching posts of profiles I've followed. I am running a gotosocial instance and the API token has read permissions. Fetching posts of my timeline works well.

2024-05-29 22:16:14.702945 CEST: Getting posts from last 80 followings
2024-05-29 22:16:14.984905 CEST: Job failed after 0:15:59.932115.
Traceback (most recent call last):
  File "/usr/bin/fedi-fetcher", line 1417, in <module>
    followings = get_new_followings(arguments.server, user_id, arguments.max_followings, all_known_users)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/fedi-fetcher", line 274, in get_new_followings
    following = get_paginated_mastodon(f"https://{server}/api/v1/accounts/{user_id}/following", max)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/fedi-fetcher", line 919, in get_paginated_mastodon
    raise Exception(
Exception: Error getting URL https://sir-photch.xyz/api/v1/accounts/REDACTED/following. Status code: 401. Ensure your access token is correct

Does my token need any more permissions, like write or admin? (As defined in: https://docs.gotosocial.org/en/latest/api/authentication/#getting-your-token)

nanos commented 4 months ago

Is your home instance running gotosocial?

Sir-Photch commented 4 months ago

Yes

nanos commented 4 months ago

In that case I'm afraid I personally can only offer very limited assistance, as I have never used GTS. Whilst FediFetcher can fetch posts from various fediverse platforms, it officially only supports running against Mastodon.

I believe that GTS has support for the Mastodon API, and thus you should be able to run FediFetcher against GTS, but I haven't tested this. And when fetching posts from GTS I have in the past noticed that GTS' implementation of the Mastodon API differs in some subtle and unexpected ways from Mastodon's implementation itself.

What I can tell you is that with mastodon a 401 response code (as seen here) means that the token you provided is not valid (e.g it's been revoked since, or you made an error when copy and pasting). Mastodon returns a 403 response instead, when the token is valid but needs more permissions. Whether GTS follows the same conventions is something I simply don't know.

You can find which permissions are required for each configuration option at the bottom of the readme file here https://github.com/nanos/FediFetcher/tree/main?tab=readme-ov-file#required-access-token-scopes, but again I don't know whether GTS requires additional scopes.

I'm happy to leave this issue open, in case anyone else can help you. If you find out the cause, please feed back here, so that we can close the issue, and potentially help others in the future.

nanos commented 3 months ago

Closing this as stale now. Feel free to reopen if needed.