Getting User Token only from server

Hi,
I want to get my userToken for my channel to access users-only enpoints of the API. How can i do this?
I’m abble to get an app accessToken but nothing else.
Thanks

You will need to create a webpage
That shows a link to Twitch
Then you click the link
Accept the request to link your Twitch and ClientID
Come back to your webpage
Grab the ?code from the query string
Exchange the code for an access + refresh token

And away you go

A node/PHP example are on my Github:

Do there is no way to get a user token only from serveur side? I just want to retrieve my sucribers list… for my own channel…
Once in get this code, how long will it be valid for ?

Not “pure server” no. You need to authenticate whenever your token+refresh is completely dead.

A Twitch user access token is valid for 4 hours.
When that token dies you can use a refresh token to generate a new token.
A refersh token has no expiraration at time of writing (and when you refresh you may get a new refresh token).

So you only need to do the webpage when you have no token/all tokens are dead.
From then on it’s all server.
Unless something causes the refresh token to be invalid, then you’ll have to webpage again to get new keys

Thanks for your help!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.