Using: access_token and client_id to setup connection to API after authorisation.
Sending a announcement chat to user, this is the result payload and sending chat works fine:
Array
(
[status] => ok
[message] =>
[api_data] =>
[endpoint] => https://api.twitch.tv/helix/chat/announcements?broadcaster_id=***&moderator_id=***
[url_params] => Array
(
[broadcaster_id] => ***
[moderator_id] => ***
)
[payload] => {"message":"Heyoooo - This is a test message! ROGER!: 2022-09-15 12:29:29", "color":"green"}
)
But, sometimes after a period, I get a response payload that user is unauthorised (I guess the sender is).
The strange thing is that I use a ‘users’ request to check if token is valid by pulling a user object from twitch does not give a 401, but responds with another user object, not the sender (bearer only). It seems that the access token is valid but dont have rights to go on. Chat not sent → unauthorised.
I need to login to twitch again, refresh tokens en then the chat works again.
What could be the issue?