-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredirect.html
More file actions
41 lines (36 loc) · 1.91 KB
/
redirect.html
File metadata and controls
41 lines (36 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Twitch Authentication Redirect</title>
<script type="text/javascript" src="meta.js"></script>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<div class="d-grid gap-2 col-6 mx-auto">
<h1>Redirecting...</h1>
</div>
<script>
// Replace with your Twitch Client ID
const clientId = "5i1dxwe52zbj0tra8evwmm4m1b7clz1";
// Check if the URL contains an access token
const urlParams = new URLSearchParams(window.location.search);
const accessToken = urlParams.get("access_token");
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
const redirectUrl = "https://streamstats.github.io/Twitch/"; // Update to your main page URL
window.location.href = `https://streamstats.github.io/Twitch/?redirect_uri=${encodeURIComponent(redirectUrl)}`;
}
</script>
</body>
</html>