Validating the access token

I’m using access token in my application to retrieve the streams. I’m generating the new token few days before the expiration time. I’m never validating the app access token before making the API request. Is this fine? or Any best practices for validating the app access token? I don’t want to validate token before every API request.

I run a background service that periodically checks the tokens and renews them if theres less than 30 mins left on them. And if I get 4xx errors on API endpoints it renews and retries.

is the validate endpoint

But since you are dealing with an app access token, theres less of a need to check per sae. The documentation note you refer to is more specific to user access tokens, as you need to check if the user has disconnect your App, and perform relevant tasks accordingly. You don’t really get a disconnecting with an app access token!

I actually have an example of such a service for app access tokens on github here

It’ll store the tokens in redis and my other services can fetch the key as they need them

You mean, is this fine if I don’t validate app access token at all. I’m generating the new app access token 10 days before the expiration time and my service will generate the new app access token, if I get 4XX errors.

What is the error codes for InvalidTokenException and ExpiredTokenException?

I don’t believe Twitch differentiates between the two.

A token that doesn’t work is a token that doesn’t work, it doesn’t tell you why it doesn’t work.

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