Quick question (as I’m still learning both Ruby & API in general).
I managed to get a Bearer token (my goal was to increase my Ratelimit from 30 to 120). However, I am unable to run more than 30 requests per minute probably because I failed to pass Bearer token properly.
Yeah. Interesting fact - it literally just started working. And I didn’t do anything ¯_(ツ)_/¯ Oh well, time to fix my loop now. And thanks for the support!
Basically, you need to make a POST request such as this POST https://id.twitch.tv/oauth2/token?client_id=<your_client_id>&client_secret=<your_secret_id>&grant_type=client_credentials
Then you get the answer with your access_token (bearer token):
"access_token": "<user access token>",
"refresh_token": "",
"expires_in": <number of seconds until the token expires>,
"scope": "<your previously listed scope(s)>",
"token_type": "bearer"
That’s it.
Also, scope is optional. And to refresh your bearer token you simply need to request a new one.
Unless you’re a dev with an old app from before token expiration was added, you can’t get an indefinite token, and even then those old tokens will eventually be revoked at some point too.
Just refresh the token a little bit of time before it expires (or in the case of an app access token, just get a new one).