From ee6e5e467f8f9f1e0a4a55e816e7ad609b19e069 Mon Sep 17 00:00:00 2001 From: Bacon_Space Date: Sat, 7 Oct 2023 16:05:17 -0400 Subject: [PATCH] Update redirect.html --- redirect.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/redirect.html b/redirect.html index 4348149..f0fd121 100644 --- a/redirect.html +++ b/redirect.html @@ -4,6 +4,7 @@ Twitch Authentication Redirect +

Redirecting...

@@ -15,16 +16,20 @@

Redirecting...

const urlParams = new URLSearchParams(window.location.search); const accessToken = urlParams.get("access_token"); - if (accessToken) { + if (!accessToken) { + // Access token is not present, initiate the Twitch login + const redirectUrl = "https://streamstats.github.io/Twitch/redirect.html"; // Update to your main page URL + const twitchAuthUrl = `https://id.twitch.tv/oauth2/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=token&scope=user:read:follows`; + + // Redirect to Twitch login + window.location.href = twitchAuthUrl; + } else { // Access token is present, save it to localStorage for later use localStorage.setItem("twitch_access_token", accessToken); // Redirect back to your main page - window.location.href = "https://streamstats.github.io/twitch/"; // Update to your main page URL - } else { - // No access token found, handle the error or redirect to an error page - console.error("No access token found."); - // You can redirect to an error page here if needed + const redirectUrl = "https://streamstats.github.io/Twitch/redirect.html"; // Update to your main page URL + window.location.href = `https://streamstats.github.io/Twitch/redirect.html?redirect_uri=${encodeURIComponent(redirectUrl)}`; }