New Twitch API - Problems with subscription no POST responses?, no ability to change title?

So, I’m about to write a small chatbot written in python, so far, I can get the my user ID, create a subscription to /helix/channels and I get a 202.

I have a flask server running to handle the callback, I see the hub.challenge and return this (as 200 status).

Example code to subscribe to event the client side:

def subscribe_to_twitch_event():
headers = {‘Authorization’: ‘Bearer {0}’.format(get_twitch_api_token()[‘access_token’])
param_data = {
‘hub.mode’: ‘subscribe’,
#‘hub.topic’: ‘https://api.twitch.tv/helix/users/follows?first=1&to_id={0}’.format('XXXXX’),
‘hub.topic’: ‘https://api.twitch.tv/helix/streams?user_id={0}’.format('XXXXX’),
‘hub.callback’: ‘http://my-endpoint-server.net/1.0/foobar/twitch/callback’,
‘hub.lease_seconds’: ‘90’,
‘hub.secret’: ‘SECRET SHHH’,
}
response = requests.post(“https://api.twitch.tv/helix/webhooks/hub”, params=param_data, headers=headers, verify=True)

def get_twitch_subscriptions():
headers = {‘Authorization’: ‘Bearer {0}’.format(get_twitch_api_token()[‘access_token’])}

response = requests.get("https://api.twitch.tv/helix/webhooks/subscriptions", headers=headers, verify=True)
print response.json()

I see:

From the initial subscription: <Response [202]>

From the check of subscription: {u’pagination’: {}, u’total’: 1, u’data’: [{u’topic’: u’https://api.twitch.tv/helix/streams?user_id=XXXXX’, u’callback’: u’http://my-endpoint-server.net/1.0/foobar/twitch/callback’, u’expires_at’: u’2018-10-24T07:27:03Z’}]}

Looks good

On the Callback side twitch is sending:

34.217.244.123 - - [24/Oct/2018 03:25:50] “GET /1.0/foobar/twitch/callback?hub.challenge=-MVIY_JIdhwLhG4icinviIMWz8gsG3pRogqIDmjg&hub.lease_seconds=90&hub.mode=subscribe&hub.topic=https%3A%2F%2Fapi.twitch.tv%2Fhelix%2Fstreams%3Fuser_id%3DXXXXXXXX HTTP/1.1” 200 -

In the GET for /1.0/foobar/twitch/callback I return the hub.challenge value the API returns 200 for http status.

When I go online, change title of stream with Streamlabs OBS, I am not getting callbacks to the POST for /1.0/foobar/twitch/callback. Doesn’t seem to be telling me there’s a response coming back.

@app.route(’/1.0/foobar/twitch/callback’, methods=[‘GET’, ‘POST’])
def _twitch_callback():
if request.method == ‘GET’:
challenge = request.args.get(‘hub.challenge’)
print(“Challenge is: {0}”.format(challenge))
return challenge
else:
print(“GOT A POST CALL!!!”)

Whats wrong?

I also don’t see any API method to let me change the stream channel title, or any way to get the stream/channel ID to change the title with the Helix API or this isn’t implemented yet?

Thanks,
Shawn.

Thats not currently in helix

As per

You can get a user by username/login or ID, which’ll return both keys

You set the webhook like time to 90 seconds.

Your hook is expiring before you go live/change your title.

You ca set a maximum of 10 days. Try setting it to something longer than 90 seconds.

I’ll try a longer lease, but the code looks right to you?

I’ll have to use the v5 API then for things not implemented though, I wonder if the deadline for December might be pushed further back.

It already has been. Theres no longer an official end date for v5.

Yup, as your Challenge is working for you so should be all good for receiving notifications.

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