-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback.html
More file actions
211 lines (186 loc) · 5.61 KB
/
callback.html
File metadata and controls
211 lines (186 loc) · 5.61 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>FlowApple // Auth</title>
<link type="image/png" sizes="96x96" rel="icon" href="https://raw.githubusercontent.com/AppleSang/flowapple/refs/heads/main/texturepack/icons8-music-heart-96.png">
<style>
* {
box-sizing: border-box;
}
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
font-family: Arial, sans-serif;
color: white;
}
/* Video background */
#bg-video {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
z-index: -1;
}
/* Centered container */
.content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
position: relative;
z-index: 1;
}
h2, p {
background-color: rgba(0, 0, 0, 0.5);
padding: 12px 24px;
border-radius: 10px;
margin: 10px 0;
}
#menu {
display: none;
margin-top: 30px;
}
button {
padding: 12px 24px;
margin: 10px;
font-size: 16px;
cursor: pointer;
border: none;
border-radius: 8px;
background-color: rgba(30, 215, 96, 0.7);
color: white;
transition: background-color 0.3s, transform 0.2s;
}
button:hover {
background-color: #14F6FA;
transform: scale(1.2);
}
/* Popup styles */
#popup {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
display: none;
justify-content: center;
align-items: center;
z-index: 10;
}
.popup-content {
background: #222;
color: white;
padding: 30px;
border-radius: 12px;
text-align: center;
min-width: 300px;
box-shadow: 0 0 20px #14F6FA;
}
.popup-content button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
background-color: #14F6FA;
color: black;
border: none;
border-radius: 6px;
cursor: not-allowed;
transition: all 0.3s ease;
}
.popup-content button.enabled {
cursor: pointer;
background-color: #1ed760;
}
</style>
</head>
<body>
<!-- Video background -->
<video id="bg-video" autoplay muted loop playsinline>
<source src="https://github.com/AppleSang/flowapple/raw/refs/heads/main/texturepack/Honey.mp4" type="video/mp4">
Trình duyệt của bạn không hỗ trợ video nền.
</video>
<!-- Nội dung chính -->
<div class="content">
<h2 id="status">Getting Current Account...</h2>
<p id="output">Please wait...</p>
<div id="menu">
<button onclick="goTo('canvas')">Canvas</button>
<button onclick="goTo('lyric')">Lyric</button>
<button onclick="goTo('player')">Widget Player</button>
</div>
</div>
<!-- Popup -->
<div id="popup">
<div class="popup-content">
<h3>⚠️ Warning ⚠️</h3>
<p>🔑 This URL contains your secret token. Avoid showing it on your stream and don't share it with other users. 🔑</p>
<button id="popup-close" disabled>Close (5s)</button>
</div>
</div>
<script>
let clientId, clientSecret, refreshToken;
async function getRefreshToken() {
const params = new URLSearchParams(window.location.search);
const code = params.get('code');
const state = JSON.parse(atob(params.get('state')));
const redirectUri = 'https://applesang.github.io/flowapple/callback';
clientId = state.clientId;
clientSecret = state.clientSecret;
const creds = btoa(`${clientId}:${clientSecret}`);
const res = await fetch('https://accounts.spotify.com/api/token', {
method: 'POST',
headers: {
'Authorization': `Basic ${creds}`,
'Content-Type': 'application/x-www-form-urlencoded'
},
body: `grant_type=authorization_code&code=${code}&redirect_uri=${encodeURIComponent(redirectUri)}`
});
const data = await res.json();
if (data.refresh_token) {
refreshToken = data.refresh_token;
document.getElementById('status').textContent = '✅ Logged in with Spotify ✅';
document.getElementById('output').textContent = 'Choose Mode:';
document.getElementById('menu').style.display = 'block';
// Show popup and start countdown
const popup = document.getElementById('popup');
const closeBtn = document.getElementById('popup-close');
popup.style.display = 'flex';
let seconds = 5;
closeBtn.textContent = `Close (${seconds}s)`;
const interval = setInterval(() => {
seconds--;
closeBtn.textContent = `Close (${seconds}s)`;
if (seconds <= 0) {
clearInterval(interval);
closeBtn.disabled = false;
closeBtn.classList.add('enabled');
closeBtn.textContent = 'Close';
closeBtn.onclick = () => {
popup.style.display = 'none';
};
}
}, 1000);
} else {
document.getElementById('output').textContent = '❌ Failed to get refresh token. Redirecting...';
console.error(data);
setTimeout(() => {
window.location.href = 'https://applesang.github.io/flowapple/';
}, 4000);
}
}
function goTo(targetPage) {
const url = `${targetPage}?cid=${encodeURIComponent(clientId)}&cs=${encodeURIComponent(clientSecret)}&rt=${encodeURIComponent(refreshToken)}`;
window.location.href = url;
}
getRefreshToken();
</script>
</body>
</html>