I’m trying to build an API to get a list of my followers and subscribers. The followers list works fine but I recive a error 401 for my subrscibers list.
I have my client ID, the scope channel:read:subscriptions.
Here the function for the subcribers :
getLastSubscribers(userId) {
const params = helpers.getUrlParams();
return request.getJson("https://api.twitch.tv/helix/subscriptions", {
broadcaster_id: userId,
// first: 20, // Limiter à 20 résultats
}, {
"client-id": CLIENT_ID,
"Authorization": `Bearer ${params["access_token"]}`,
}).then(function(data) {
return data.data;
});
}
Here a printscreen of the console : [ADMIN REMOVED LEAKED TOKEN]
I can provide the rest of the code if needed
Thank you
You just leaked a token.
I edited your post to remove the image.
Please revoke that token!
The token is of type user and not a client credentials token? And the token is for the broadcaster in question?
I checked your leaked token, the leaked token belongs to mimilapuce
of ID 408679779
and your code above was looking up 146319684
who is snakepeaceguard
So you used the wrong persons token, if mimilapuce
is a mod of snakepeaceguard
then you can get followers, but subscribers needs the broadcasters token
I remove the app with the leaked token and create a new one, sorry about that .
The token is for the brodcaster. I try to create an app for my boyfriend to show the last follower and subscriber.
If I understand well to use his token I have to register the app in his account instead of mine ?
No need to delete the whole app.
Just revoke that token - Revoking Access Tokens | Twitch Developers - Token Checker | Twitch API Example
No, the owner/registrant of the app is irrelevant
You just need to authenticate the right users to the application.
So far you authed mimilapuce
to your ClientID.
Your just need to give snakepeaceguard
a URL to go to to authenticate with. So they auth as them instead of you.
Whom owns the clientID just doesn’t matter.
Thank you Barry, I try with my information and the subscibers showed
I hit another wall
It’s seems thaht my list is filtred because I recived my information only.
Here the code :
getLastSubscribers(userId) {
const params = helpers.getUrlParams();
return request.getJson("https://api.twitch.tv/helix/subscriptions", {
broadcaster_id: userId,
first: 20,
}, {
"client-id": CLIENT_ID,
"Authorization": `Bearer ${params["access_token"]}`,
}).then(function(data) {
return data.data;
});
}
And here the array :
Thank for your help
You asked for the subscribers of 408679779
and got the subscribers of 408679779
There’s one piece of information I must be missing.
On the reference page Reference | Twitch Developers it is specified to use the brodcaster_id to receive the list of subscribers.
From what I’ve read the broadcaster_id and user_id are the same thing, so it should send a non-filtered list because if I remove broadcaster_id: userId nothing will work.
Correct.
A different label is used to differentiate the entities in the request.
I am barrycarlyon
of ID 15185913
I subscribe to cohhcarnage
whom is ID 26612034
I own my ClientID and I have cohhcarnage authed to my clientID
So I use cohhcarnage’s token and ID to get his subscribers
So to get all cohhcarnage’s Subscribers https://api.twitch.tv/helix/subscriptions?broadcaster_id=26610234
and to see if barrycarlyon
is a subscriber of cohhcarnage
using cohhcarnage
s token https://api.twitch.tv/helix/subscriptions?broadcaster_id=26610234&user_id=15185913
Both usernames were converted to ID’s using Get Users. Then the userID used with the right parameters in the request.
So to get all the subscibers of snakepeaceguard
you need to call https://api.twitch.tv/helix/subscriptions?broadcaster_id=146319684
using a token that represents snakepeaceguard
but you asked for the subscribers of 408679779
as thats what you stated the broadcaster was.