I’m trying to integrate drops into my indie game, but I’m currently having some issues connecting a webhook to the “Drop Entitlement Grant” hook.
I’ve gotten everything working with the CLI tool with the mock data that is fed, even the challenge succeeds so that isn’t an issue.
I’ll show you the typescript code I’m using to request the webhook.
export const subscribeTwitchHook = async () => {
const options = {
method: "POST",
url: `https://api.twitch.tv/helix/eventsub/subscriptions`,
headers: {
"Client-ID": TWITCH_ID,
Authorization: "Bearer " + (await getToken()),
"Content-Type": "application/json",
},
data: {
type: staticVars.twitchHookTypes,
version: "1",
condition: {
organization_id: TWITCH_ID,
},
transport: {
method: "webhook",
callback: "https://wookhang.com/twitch/eventsub",
secret: TWITCH_SECRET,
},
is_batching_enabled: true,
},
};
try {
const { data } = await axios(options);
console.log(`Twitch hook subscription: ${JSON.stringify(data)}`);
} catch (err) {
console.log(err);
}
};
I’ll clarify that the webhook is over https on port 443, the auth token I’m using is a client auth token.
Additionally i will post my code that requests the auth token.
const getToken = async (): Promise<string> => {
if (clientToken && clientToken.expires_in > Date.now()) {
return clientToken.access_token;
}
try {
const response = await axios.post("https://id.twitch.tv/oauth2/token", {
client_id: TWITCH_ID,
client_secret: TWITCH_SECRET,
grant_type: "client_credentials",
});
clientToken = response.data;
clientToken.expires_in = Date.now() + clientToken.expires_in * 1000;
return response.data.access_token;
} catch (err) {
console.log(err);
return "";
}
};
The error I receive when I try requesting the webhook is.
data: {
error: 'Forbidden',
status: 403,
message: 'subscription missing proper authorization'
}
Seems like my auth token is invalid or maybe I’m missing something in the options when requesting my client token. Can anyone point me in the right direction?