Hello,
I’m currently testing around with pubsubs. At the moment I have the problem that I have to send an authtoken within the request. The problem is that I only have the accesstoken, refreshtoken … So how do I work around that problem, do I have to request the authtoken oder how can I use pubsubs without the authtoken.
When I pass the accestoken as authtoken it responses with:
{“type”:“RESPONSE”,“error”:“ERR_BADAUTH”,“nonce”:""}
My code
socket.onopen = (event: any) => {
console.log(“Connection established”);
let data = {
"type": "LISTEN",
data: {
"topics": ["channel-bits-events-v1.44322889"],
"auth_token": accessToken
}
}
socket.send(JSON.stringify(data));
}
Hopefully anyone can help me with that problem
Thank you
Shorty
So do I have to pass a scope within the request or when I redirect the user to authenticate my app?
At the moment I only ask for the ‘user:edit’ scope.
Step 1) Redirect user to twitch on that URL
Step 2) Exchange the returned code for a access token aka auth token (they are one and the same)
Step 3) ???
Step 4) Profit
Im really sorry for asking again but I got the authtoken now. How do I get the accesstoken, refreshtoken…?
I cant find the url for requesting it with the authtoken.
Okay,
so I tried to change some things. For example downgrading to kraken API getting credentials and stuff from the kraken API(https://api.twitch.tv/kraken/oauth2/token?, …).
I still get the same error like mentioned above.
Step 2) Exchange the returned code for a access token aka auth token (they are one and the same)
No, thats the example url. My bad.
I changed it to the correct userId and it still gives me the same error.
I requested the userId from the (https://api.twitch.tv/kraken/user) endpoint
Make sure that the token is valid, has the correct scope, and the user id in the token matches that of the user id in the topic you’re attempting to listen to on Pubsub.
Well I finally found the error.
I needed to switch to the kraken API in order to use it and I had the ‘user_subscriptions’ instead of ‘channel_subscriptions’ scope…