Hey im trying to build a discord bot that with have some twitch integration to post live announcements, like streamcord,
I’m using Client Credentials Grant Folw to get the App Access Token but constantly get Failed to acquire Twitch App Access Token errors, I have checked that my client id and secret id are correct in my code but I don’t seem to be getting anywhere.
whats the body of the response? it should describe the error and what to fix.
And/or what does your code look like?
This is my code, the only response I get is Failed to acquire Twitch app access token
twitch_client_id = self.config.get("TWITCH_CLIENT_ID")
twitch_client_secret = self.config.get("TWITCH_CLIENT_SECRET")
logging.getLogger('twitchAPI').setLevel(logging.DEBUG)
if not twitch_client_id or twitch_client_id == "YOUR_TWITCH_CLIENT_ID_HERE" or \
not twitch_client_secret or twitch_client_secret == "YOUR_TWITCH_CLIENT_SECRET_HERE":
main_logger.warning("TWITCH_CLIENT_ID or TWITCH_CLIENT_SECRET not found or is default in config.json! Twitch integration will be disabled.")
self.twitch_api = None # Explicitly set to None if not usable
else:
try:
self.twitch_api = Twitch(twitch_client_id, twitch_client_secret)
if await self.twitch_api.authenticate_app([]):
main_logger.info("TwitchAPI client (App Access Token) initialized successfully.")
else:
main_logger.critical("Failed to acquire Twitch App Access Token. Twitch API features may be limited.")
self.twitch_api = None
except Exception as e:
main_logger.critical(f"Error initializing TwitchAPI client: {e}", exc_info=True)
self.twitch_api = None
Thats what you logged out, an “interpreted” response, not the error from the Twitch API itself.
But whats the body of the response?
This call
Fails and then you just log “it failed” but you don’t put out any useful information. Such as what the API responded with
Wheres this code/function
Or if it’s a library which library?
This function is in my discord bots main startup functions, they only responce im getting in my logs is:
] main: Starting Twitch API initialization process.
[2025-07-09 11:36:35] [DEBUG ] main: Retrieved Twitch Client ID: *****
[2025-07-09 11:36:35] [DEBUG ] main: Retrieved Twitch Client Secret: *****
[2025-07-09 11:36:35] [DEBUG ] main: Attempting to create Twitch client object…
[2025-07-09 11:36:35] [DEBUG ] main: Twitch client object created. Attempting to acquire app access token…
[2025-07-09 11:36:35] [DEBUG ] twitchAPI.twitch: generating fresh app token
[2025-07-09 11:36:36] [CRITICAL] main: Failed to acquire Twitch App Access Token. Twitch API features may be limited.
[2025-07-09 11:36:36] [DEBUG ] main: App access token acquisition failed. self.twitch_api set to None.
[2025-07-09 11:36:36] [DEBUG ] main: Finished Twitch API initialization block.
You need to modify your code to obtain and display the API response.
Inside this function if await self.twitch_api.authenticate_app([]):
So normally that would be (in JS)
let token_url = new URL('https://id.twitch.tv/oauth2/token');
token_url.search = new URLSearchParams([
[ 'client_id', process.env.client_id ],
[ 'client_secret', process.env.client_secret ],
[ 'grant_type', 'client_credentials' ]
]).toString();
let r = await fetch(
token_url,
{
method: "POST",
headers: {
"Accept": "application/json"
}
}
);
if (r.status != 200) {
console.log('Failed to get a token', await resp.text());
// likely a _BAD_ error so we won't retry
return;
}
// else got a token process the JSON...
That on a fail will log the body of the response so it can be understood why the call failed
used this idea and modiyfied it to python and now its working, sucessfully recieved a access token :D, love that trying to debug it fixed the issue
Thank you for your help