# Channel/Followers returning empty data set

**URL:** <https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179>\
**Category:** API\
**Created:** [June 20, 2023, 12:35pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179 "2023-06-20T12:35:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeRurik](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@LeRurik](https://staging-discuss.dev.twitch.com/u/LeRurik)\
**Post date:** [June 20, 2023, 12:35pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/1 "2023-06-20T12:35:16Z")

</div>

I am having issues with the channel/followers endpoint. It is returning just the total amount and not the data list.  
I am using a wrapper mentioned by twitch [GitHub - romanzipp/Laravel-Twitch: Twitch Helix API PHP Wrapper for Laravel](https://github.com/romanzipp/Laravel-Twitch).

```auto
$result = $twitch->getOAuthToken(null, GrantType::CLIENT_CREDENTIALS, ['channel:read:subscriptions', 'moderator:read:followers']);
        if ( ! $result->success()) {
            return;
        }

        $accessToken = $result->data()->access_token;
        $twitch->setToken($accessToken);

        $usersResult = $twitch->getUsers(['login' => 'LeRurik']);
        if ( ! $usersResult->success()) {
            return null;
        }

        $user = $usersResult->shift();
        $broadcasterId = $user->id;

        do {
            $nextCursor = null;

            if (isset($followers)) {
                $nextCursor = $followers->next();
            }

            $followers = $twitch->getChannelFollowers(['broadcaster_id' => $broadcasterId], $nextCursor);

            foreach ($followers->data() as $item) {
            }

        } while ($followers->hasMoreResults());

```

I have the right scope, I am authenticating correctly with my own app which is set up, as far as I can tell, under my main twitch account, LeRurik. This is the same account that I am querying followers for. The follower count matching suggests that its the correct account.

Any idea why I would not be getting the data?

The usual suggestion is that either the scope is missing, or that the authenticated user is not a mod on the channel. But how can I not be a mod of my own channel?

I have been trying to investigate this for a few hours now and am starting to get a bit frustrated, so any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 12:36pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/2 "2023-06-20T12:36:09Z")

</div>

> [@LeRurik](#):
>
> `GrantType::CLIENT_CREDENTIALS`

This is the wrong token type

Client creds _basically_ can’t have scopes

To read _whom_ follows _who_ via the API requires a USER TOKEN not a Client Credentials token

> **[Reference](https://dev.twitch.tv/docs/api/reference/#get-channel-followers)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

> Requires a [user access token](https://dev.twitch.tv/docs/authentication#user-access-tokens) 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.

You have the wrong token type

---

<div class="post-metadata">

**Author:** ![LeRurik](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@LeRurik](https://staging-discuss.dev.twitch.com/u/LeRurik)\
**Post date:** [June 20, 2023, 1:31pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/3 "2023-06-20T13:31:38Z")

</div>

It’s probably just late and I am not thinking clearly, but…

If I use the GrantType::AUTHORIZATION\_CODE to get the access token at login, I then can’t actually log in the user. I also can’t get their display name/avatar for the user area because for that I would need their username or ID in the first place, which there doesn’t seem to be an endpoint for getting the user details for the current oauthed user?

I was able to successfully get the access token for myself by logging into my own site as myself, but it kind of defeats the purpose if I can’t get the rest of the info to go with it, as the code is one use only.

Sorry if this seems to be asking for too much help here, but I don’t see how I can do both flows with one code (create a user and get their access token), nor how I can only get the access token for my own account, as I don’t need or care about getting one for other users.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 1:33pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/4 "2023-06-20T13:33:13Z")

</div>

> [@LeRurik](#):
>
> If I use the GrantType::AUTHORIZATION\_CODE to get the access token at login, I then can’t actually log in the user. I also can’t get their display name/avatar for the user area because for that I would need their username or ID in the first place, which there doesn’t seem to be an endpoint for getting the user details for the current oauthed user?

You call Get users without an ID or Login _just_ the Access token and it will return the User for that token

> **[Reference](https://dev.twitch.tv/docs/api/reference/#get-users)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

Or you can call the [validate endpoint](https://dev.twitch.tv/docs/authentication/validate-tokens/) which will validate the token and return the `user_id` and `login` for the token. (Easy way to see what kind of token you have as well)

Example: [Twitch Implicit Auth Example](https://barrycarlyon.github.io/twitch_misc/authentication/implicit_auth/) (when Github pages deploys in a moment)

> <https://github.com/BarryCarlyon/twitch_misc/blob/main/authentication/implicit_auth/index.html#L40>

---

<div class="post-metadata">

**Author:** ![LeRurik](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@LeRurik](https://staging-discuss.dev.twitch.com/u/LeRurik)\
**Post date:** [June 20, 2023, 9:11pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/5 "2023-06-20T21:11:33Z")

</div>

You were right, I forgot to actually set the access token, which is why it was complaining.

I have decided to go a slightly different route as I don’t want to retrieve an access token for every user currently, but I now know what was going wrong and how I can do it this way.

However, the last stumbling block I possibly see is:

```auto
{"grant_type":"authorization_code","client_id":"","client_secret":"","redirect_uri":"","code":"","scope":"channel:read:subscriptions moderator:read:followers"}  
{"access_token":"","expires_in":15196,"refresh_token":"","scope":["user:read:email"],"token_type":"bearer"}

```

I have removed the sensitive information, but as you can see, I requested the additional scopes, but the access token that was returned states that it only has the `user:read:email` scope? Does that sound right, or is something still going wrong there?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 9:13pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/6 "2023-06-20T21:13:11Z")

</div>

Scopes go on the outbound `<a href=""` that a user clicks on

Not in the code to token exchange

---

<div class="post-metadata">

**Author:** ![LeRurik](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@LeRurik](https://staging-discuss.dev.twitch.com/u/LeRurik)\
**Post date:** [June 20, 2023, 9:30pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/7 "2023-06-20T21:30:47Z")

</div>

I thought that might be the case. Thank you for your help. I will test it and confirm it with my new flow, but I think this will likely solve my issues.

---

<div class="post-metadata">

**Author:** ![LeRurik](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@LeRurik](https://staging-discuss.dev.twitch.com/u/LeRurik)\
**Post date:** [June 20, 2023, 9:58pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/8 "2023-06-20T21:58:44Z")

</div>

Confirmed, I now have it working perfectly. Thank you for all the assistance Barry. I should be right to work with the API from here now that I have valid auth flows.

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [July 20, 2023, 9:59pm UTC](https://staging-discuss.dev.twitch.com/t/channel-followers-returning-empty-data-set/46179/9 "2023-07-20T21:59:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
