Closed chrisderwahre closed 6 years ago
Have you set a client ID?
You mean like this?
public Bot() { this.setUsername(Secrets.username); this.setOauth_Key(Secrets.key); this.setClientID(Secrets.clientID); }
Yeah like that. I will have a look into it ^^
Oh yeah the implementation is experimental and apparently incorrect. I might make a commit tomorrow fixing the issue.
Further the OAuth token must have been required with scope channel_subscriptions
according to the Docs here
Ok sound good.
Yeah, I'm so sorry for this, when I implemented it I had no one who was a partner to test it on so I made it really similar to the follower and followed the docs that may have changed since.
I created the patch now on the brach "subpatch". I have the same issue like cavariux tho. As I am not subscribed to any channels nor know anyone, I cannot test it.
An important note: The code requires your OAuth-token to include the scope channel_check_subscription
! Meaning that the OAuth token acquired for the bot does NOT have sufficient permissions and will return 401 - Unauthorized. I am not entirely sure how to obtain such a token unfortunately (guess you will have to create your own application online and let people authorize it to acquire such a token) and if it has to be agreed on by the user or the channel-owner.
i have currently no time,you can try it with the channel 'fameundriches' (im subscribed to this channel (my twitch name is 'ChrisderWahre' too.))
Alright I found some mistakes in my code and stuff but the main issue is the oAuth token. I found a website that lets you acquire such a token here.
After my understanding you have to do the following: Go to your twitchapps here, create a new application with the redirect url given on the website (https://twitchapps.com/tokengen/
) and note the client ID of that (or if your bot doesn't have a redirect url you can use your bot for that as well and set its redirect url to that).
Then you ask the person whose channel you want to know the subscription of, to open that website and fill in the following:
Client-ID: The noted clientId of your project
Required Scope: channel_check_subscription
Then ask them to click "Connect with Twitch". This will bring them to a confirmation site that will ask them if they agree that it can read their channels subscriptions. If they confirm that, they will see a website with a small field containing the oAuth token you need to provide if you want to check if someone is subscribed to their channel.
@chrisderwahre If you could verify that the above process is working, that would be much appreciated :)
Ill have a look at it. Give me a Minute.
Result:
java.io.IOException: Server returned HTTP response code: 401 for URL: https://api.twitch.tv/kraken/channels/119606589/subscriptions/143994027
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.cavariux.twitchirc.TwitchAPIConnections.ChannelQueries.isSubscriber(ChannelQueries.java:30)
at com.cavariux.twitchirc.Chat.Channel.isSubscribed(Channel.java:289)
at com.cavariux.twitchirc.Chat.User.isSubscribed(User.java:110)
at core.FritzderWahre.onMessage(FritzderWahre.java:69)
at com.cavariux.twitchirc.Core.TwitchBot.start(TwitchBot.java:346)
at core.main.main(main.java:44)
Code:
if (message.contains("subscheck")) {
if (user.isSubscribed(channel, Secrets.suboauth) == true) {
this.sendMessage("@" + user + " You are a Sub, Cool!", channel);
} else {
this.sendMessage("@" + user + " You are not a Sub, not Cool!", channel);
}
}
Would have been too easy anyway ;) I will include this for my March run in this repo and by then hopefully found someone who agreed on letting me use their token.
Hey @geisterfurz007 , i would let you use my Token, do you have Discord or Twitter? My Discord: ChrisderWahre#9694 my Twitter: ChrisderWahre. :)
I contacted you on Discord :) Thanks for the offer already!
This still requires testing. If someone is close with a streamer who has subscribers, please do the following:
Go to your twitchapps here, create a new application with the redirect url given on the website (https://twitchapps.com/tokengen/) and note the client ID of that (or if your bot doesn't have a redirect url you can use your bot for that as well and set its redirect url to that). Then you ask the person whose channel you want to know the subscription of, to open that website and fill in the following: Client-ID: The noted clientId of your project Required Scope: channel_check_subscription Then ask them to click "Connect with Twitch". This will bring them to a confirmation site that will ask them if they agree that it can read their channels subscriptions. If they confirm that, they will see a website with a small field containing an oAuth token. Ask them to give it to you.
Use the token you got from them in the method isSubscribed
or contact me on discord under geisterfurz007#5952
.
I'll test the sub things, I'm recently affiliated. (This was the proposal that I forgot about earlier)
Hey everyone, i have an issue if i check for the subscribed == true here the full event:
here the error:
am i doing something wrong or is it an issue with the API?