Since I don’t understand your questions, I’ll just post some more actual code. This is the class I used to subscribe to follower notifications:
class TwitchWebhookInterface(object):
def __init__(self, logger, follow_server):
self.logger = logger
self.follow_server = follow_server
add_configuration(self)
self.webhooks_url = f"{self.twitch_api_base}/webhooks/hub"
self.interface = TwitchChannelInterface(self.channel, self.client_id)
self.user_id = self.interface.get_id()
def subscribe(self):
headers = {"Client-ID": self.client_id}
data = {
"hub.mode": "subscribe",
"hub.topic": f"{self.twitch_api_base}/users/follows?first=1&to_id={self.user_id}",
"hub.callback": self.public_uri,
"hub.lease_seconds": str(24 * 60 * 60)
}
result = requests.post(self.webhooks_url, json=data, headers=headers)
if result.status_code == requests.codes.accepted:
self.logger.debug("Our subscription request was accepted by Twitch")
else:
self.logger.debug("Failed to subscribe to follower notifications")
self.logger.debug(f"result.status_code = {result.status_code}")
self.logger.debug(f"result.text = {result.text}")
The part that no longer works is the part that gets the “client_id”:
self.interface = TwitchChannelInterface(self.channel, self.client_id)
self.user_id = self.interface.get_id()
I can’t get the “user_id” anymore, because Twitch wants my bot to login using OAuth. This is the part where you have been singularly unhelpful. How do I programmatically log a bot into Twitch? My bot isn’t a human sitting at a computer using a web browser. My bot is a Python script. Previously, I used code like this to get the “user_id”:
def get_id(self):
api_url = f"{self.twitch_api_base}/users"
headers = {"Client-ID": self.client_id}
payload = {"login": self.channel}
result = requests.get(api_url, params=payload, headers=headers)
if result.status_code == requests.codes.ok:
self.data = result.json()
self.channel_id = self.data['data'][0]['id']
return self.channel_id
This worked when no OAuth was required. This no longer works. So, once again, how do I get that “user_id” (AKA “channel_id”)? Can you think of minimal changes to this specific method that might fix the problem?