Hello,
I am a noobie in programming network-based programms.
I would like to use EventSub in python but I get the following error:
{‘error’: ‘Bad Request’, ‘status’: 400, ‘message’: ‘invalid transport’}
There is already a post about this error, but I didn’t understood the answer.
[EventSub - Trying to send the challenge response ]
In python:
url = f"https://api.twitch.tv/helix/eventsub/subscriptions "
headers = {“Client-ID”: self.CLIENT_ID,
“Authorization”: “Bearer 2usysigpkwy25b427d8qz9h9vXXXXX”,
“Content-Type”: “application/json”}
post(url, headers=headers).json()
I don’t have a clue what’s going wrong.
Things I have tried:
Running this command in cmd (same error)
Expose a web server on port 80 using ngrok: ngrok http 443
Thanks in advance.
James_Un:
In python:
url = f"https://api.twitch.tv/helix/eventsub/subscriptions "
headers = {“Client-ID”: self.CLIENT_ID,
“Authorization”: “Bearer 2usysigpkwy25b427d8qz9h9vXXXXX”,
“Content-Type”: “application/json”}
post(url, headers=headers).json()
I don’t have a clue what’s going wrong
You seem to have not included a copy of your HTTP Post body for us to debug, so I’m guessing you didn’t send any at all. So that is likely your problem. You didn’t ask for a topic or specify a transport.
Here is a nodeJS example from my github
console.log(subscriptions_valid);
for (var topic in subscriptions_valid) {
if (!subscriptions_valid[topic]) {
console.log('Create', topic, subscriptions_to_make[topic]);
createSubscription(topic, subscriptions_to_make[topic]);
}
}
}
function createSubscription(type, thing) {
var condition = {};
condition[thing] = broadcaster_id;
var json = {
type,
version: "1",
condition,
transport: {
method: 'webhook',
callback: app_access_token.callback_url,
Relevant snippet
var json = {
type,
version: "1",
condition,
transport: {
method: 'webhook',
callback: 'some url',
secret: 'some jibberish'
}
};
Kolyall
February 15, 2021, 10:10pm
3
Hello, pls , help me too. I make:
method: 'POST',
url: 'https://api.twitch.tv/helix/eventsub/subscriptions',
headers:
{ 'Client-ID': '{{MY_CLIENT_ID}}',
Authorization: 'Bearer {{APP_AUTH_TOKEN}}' },
responseType: 'text',
data: '{{challenge}}'
But response is :
{
"error": "Bad Request",
"status": 400,
"message": "invalid transport"
}
See line 72/77 and 80 of
const fs = require('fs');
const path = require('path');
const got = require('got');
const client_config = JSON.parse(fs.readFileSync(path.join(
__dirname,
'..',
'jsons',
'config_client.json'
)));
const account_config = JSON.parse(fs.readFileSync(path.join(
__dirname,
'..',
'jsons',
'config_user.json'
)));
const app_access_token = JSON.parse(fs.readFileSync(path.join(
__dirname,
'..',
This file has been truncated. show original
You are not replying to the challenge correctly.
You don’t send a POST request you just echo out the body.
Kolyall
February 15, 2021, 10:33pm
5
Can you pls help me one more time. I still don’t understand. How to make it on Node.js?
I literally linked your a node.js example of a server application…
and
Are both node.js examples of an EventSub Server
Kolyall
February 15, 2021, 11:07pm
7
Thanks, understood. I just need to make answer(response) string encodeURIComponent(req.body.challenge)
for POST request from twitch
system
Closed
March 17, 2021, 11:08pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.