Cant login as bot in python

A token of type client_credentials won’t let you login to chat.

It doesn’t have scopes on it (even though you requested)

To login to chat you need a user token (response_type code) that has the relevant chat scopes on it, and the access_code you exchange for needs to be for the user of “nickname” in your code.

The oAuth loop is done separately to your main bot code flow, since it needs a web server (even a localhost one) and user interaction to validate/access the permission(s), and you just throw a refresh token loop in instead.