Hello everyone i have a good knowledge regarding programming but in terms of connections e.t.c i’m amateur. I’m trying 2 days now to follow this: Authentication | Twitch Developers
and make a code so i can get data from specific users via JSON but i fail.
So far i managed to generate a client-id but afterwards i don’t know what i need to do to continue. I cannot understand this “Bearer” oath thing it requires and how i get mine.
Is anyone able to give me a hand. Thanks in advance.
After obtaining a ClientID you then build an oAuth flow.
That oAuth flow is a webpage that users go to
They click a link
That link takes them to Twitch
They accept (or decline) to share data between their twitch account and your Application.
Then depending on the flow they return to your site with a ?code= that you can exchange for an access token, or a #access_token you can then use to make requests with.
This is generally what you do for apps that are pure front end JS you use implict auth and get the #access_token version
If you need to do actions as a user on a server then you use regular oauth and get the ?code= to exchange for an access token (and refresh token) so you can then do “offline processing”
If you are only dealing with public data and have a server, then you generate an app access token and use that for server to server requests. So to lookup user data, a user fills in a form on your website thats posts to your server and the server makes the call to Twitch and processes the response.
Is a bit vauge on what you are trying to do.
If you already have a list of users then an App Access Token works on a script/server to collect this data.
If you want people to login to your site and you get that persons data then you need an oAuth flow that logs the user in
Thank you for your fast response first of all. I’m using java and i really can’t understand the links of those redirects in order to obtain an auth code. Guide in twitch is kinda unfriendly for new developers.
I basically want to create a code for a “emulator game” i have which get the streamer data and twitch channels info. So basically i want query a twitch channel and get it’s info + the user’s info (the owner of the channel). Those i need.
So i followed your link and i received a token:
Your Access Key from the #url: lfx6vel#################
I guess this is the Bearer they say? So i guess i do a request for a twitch channel?
PS. I Tried use it like this
URL obj = new URL("https://api.twitch.tv/helix/search/channels?query=a_seagull");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestProperty("Authorization", "Bearer lfx6velftvo8####");
Yes it does, in Java setRequestProperty set a connection header.
Still i don’t get why it don’t work. I used my client-id and the auth code it generated from your site.
Maybe it has something to do with Bearer? How we use this thing anyway