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.
So
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.
As i said i already created my Client-ID and my Secret ID from Twitch Developers.
Now i guess i need to use some url to add those 2 id’s as header and request some Bearer code?
That what i’m asking the steps until the moment that i can do a HTTP request and get data for users.
A little but it’s “industry standard oAuth” so it roughly follows the oAuth specific used by many sites/services to create links between Client’s and Users.
What are you actually trying to do.
I outlined three different authentication methods in my first reply and the one to use depends on what you are doing.
If you have the username or ID then you can use an App Access Token to load publc data
If you want to get information about the logged in user then you use token you got from the authentication loop.
The simplest is this implict auth example, which just needs a WebBrowser and Javascript. No java involved
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.setRequestMethod("GET");
con.setRequestProperty("Client-ID", "1mnq9hg20ml####");
con.setRequestProperty("Authorization", "Bearer lfx6velftvo8####");
con.connect();
System.out.println(con.getResponseMessage());
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