# Telegram Bot that retrieve channel subscriptions list

**URL:** <https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512>\
**Category:** API\
**Created:** [April 30, 2021, 8:24pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512 "2021-04-30T20:24:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omnius1234](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/omnius1234/32/12040_2.png) [@Omnius1234](https://staging-discuss.dev.twitch.com/u/Omnius1234)\
**Post date:** [April 30, 2021, 8:24pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/1 "2021-04-30T20:24:12Z")

</div>

Hi,i’m sorry if my english will be bad 😅

I’m requesting help because i’m stacking with a problem : i’m developing a telegram bot that automatically kick user that is not subscribed to a channel,in this moment i use the channel csv subscriber list.

Now, what i want to achieve is : get the list of subscriber from the twitch api, i alredy have the client\_secret and client\_id of the twitch channel of which I want to get the subscriber list and i have alredy tested the api to obtain the token

```auto
GET https://id.twitch.tv/oauth2/authorize
    ?client_id=<your client ID>
    &redirect_uri=<your registered redirect URI>
    &response_type=code
    &scope=<space-separated list of scopes>

```

but when i use thi endpoint and pass the token i get 401 Unauthorized

```auto
curl -X GET 'https://api.twitch.tv/helix/subscriptions?broadcaster_id=141981764' \
-H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' \
-H 'Client-Id: uo6dggojyb8d6soh92zknwmi5ej1q2'

```

I hope you could help me

---

<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:** [April 30, 2021, 8:27pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/2 "2021-04-30T20:27:29Z")

</div>

That would suggest you didn’t complete step 3 of oAuth and exchange the code for a token.

> **[Getting OAuth Access Tokens](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/)**
>
> Getting OAuth Access Tokens

```auto
3) On your server, get an access token by making this request:

POST https://id.twitch.tv/oauth2/token
    ?client_id=<your client ID>
    &client_secret=<your client secret>
    &code=<authorization code received above>
    &grant_type=authorization_code
    &redirect_uri=<your registered redirect URI>
Here is a sample request:

POST https://id.twitch.tv/oauth2/token
    ?client_id=uo6dggojyb8d6soh92zknwmi5ej1q2
    &client_secret=nyo51xcdrerl8z9m56w9w6wg
    &code=394a8bc98028f39660e53025de824134fb46313
    &grant_type=authorization_code
    &redirect_uri=http://localhost

```

---

<div class="post-metadata">

**Author:** ![Omnius1234](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/omnius1234/32/12040_2.png) [@Omnius1234](https://staging-discuss.dev.twitch.com/u/Omnius1234)\
**Post date:** [April 30, 2021, 8:34pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/3 "2021-04-30T20:34:24Z")

</div>

tnx for reply me,

how i get the code if i need to login with theese request to obtain it so the channel owner can’t login?

---

<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:** [April 30, 2021, 8:41pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/4 "2021-04-30T20:41:43Z")

</div>

oAuth is as follows

1. Redirect the User to Twitch
2. User is redirect to your website with a ?code
3. Exchange the ?code for a token (and refresh token)

> [@Omnius1234](#):
>
> obtain it so the channel owner can’t login?

In order to get access to the broadcasters subscription list, you need permission from the broadcaster. So the braodcaster has to login in order to grant that access

---

<div class="post-metadata">

**Author:** ![Omnius1234](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/omnius1234/32/12040_2.png) [@Omnius1234](https://staging-discuss.dev.twitch.com/u/Omnius1234)\
**Post date:** [April 30, 2021, 8:44pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/5 "2021-04-30T20:44:10Z")

</div>

ok,so having client\_id and client\_secret are not enough…ok tnx,

when i get the code,does it expire?

---

<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:** [April 30, 2021, 8:44pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/6 "2021-04-30T20:44:53Z")

</div>

a `?code` is one use

A token, has an expire time which is returned when you get it from the API you can also use the validate endpoint to get the current expires\_in

Then use the refresh token to get a new access token

---

<div class="post-metadata">

**Author:** ![Omnius1234](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/omnius1234/32/12040_2.png) [@Omnius1234](https://staging-discuss.dev.twitch.com/u/Omnius1234)\
**Post date:** [April 30, 2021, 8:48pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/8 "2021-04-30T20:48:14Z")

</div>

tnx you for helping me

---

<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:** [May 30, 2021, 8:48pm UTC](https://staging-discuss.dev.twitch.com/t/telegram-bot-that-retrieve-channel-subscriptions-list/31512/9 "2021-05-30T20:48:15Z")

</div>

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