This commit is contained in:
2025-06-30 18:59:23 +01:00
parent e868153bbb
commit eb35a62523

View File

@ -42,15 +42,24 @@ export const twitchFollowEvent = z.object({
// Webhook -> Redeem of channel reward
export const createTwitchClient = () => {
const getAccessToken = async () => {
const twitchAuthResponse = await fetch(
`https://id.twitch.tv/oauth2/token?client_id=${TWITCH_APP_CLIENT_ID}&client_secret=${TWITCH_APP_SECRET}&grant_type=client_credentials&&redirect_uri=https://twitch.johncosta.tech/redirect&scope=moderator:read:followers`,
{
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
const authUrl = `https://id.twitch.tv/oauth2/authorize` +
`?response_type=code` +
`&client_id=${TWITCH_APP_CLIENT_ID}` +
`&redirect_uri=${encodeURIComponent("https://twitch.johncosta.tech/redirect")}` +
`&scope=moderator:read:followers`
const twitchAuthResponse =
await fetch(
authUrl,
{
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
},
},
);
);
const { access_token } = authBodyValidator.parse(
await twitchAuthResponse.json(),