Teekeks / pyTwitchAPI

A Python 3.7 compatible implementation of the Twitch API, EventSub, PubSub and Chat
https://pytwitchapi.dev
MIT License
254 stars 38 forks source link

Allow using `get_channel_followers` endpoint without user auth #262

Closed gxtu closed 1 year ago

gxtu commented 1 year ago

For my application I am only using app authentication and only need a user's total follower count, but when I call get_channel_followers I'm getting an UnauthorizedException.

The API reference for the get_channel_followers endpoint specifies (emphasis mine):

Requires a user access token that includes the moderator:read:followers scope. The ID in the broadcaster_id query parameter must match the user ID in the access token or the user must be a moderator for the specified broadcaster. If a scope is not provided, only the total follower count will be included in the response

This is admittedly still a bit ambiguous (does it still require user auth even if no scope is needed?), but developer forum posts like this one suggest that if you're only interested in the follower count (and thus don't need a scope), using app authentication is enough.

So when I change this line to return await self._build_iter_result('GET', 'channels/followers', param, AuthType.EITHER, [], ChannelFollowersResult), the request actually goes through fine and I get the total number of followers back.

Could the function be changed to accomodate this use of the Twitch API?