-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback.html
More file actions
62 lines (56 loc) · 2.37 KB
/
callback.html
File metadata and controls
62 lines (56 loc) · 2.37 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spotify Authorization</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body
class="bg-gradient-to-br from-gray-900 via-green-900 to-gray-900 text-white min-h-screen flex items-center justify-center">
<div class="text-center">
<div class="animate-spin text-6xl mb-4">🎵</div>
<h1 class="text-2xl font-bold mb-2">Authorizing Spotify...</h1>
<p class="text-gray-400">Please wait while we complete your login</p>
</div>
<script>
// Extract token from URL hash
const hash = window.location.hash.substring(1);
const params = new URLSearchParams(hash);
const accessToken = params.get('access_token');
const error = params.get('error');
if (error) {
// Handle authorization error
document.body.innerHTML = `
<div class="text-center">
<div class="text-6xl mb-4">❌</div>
<h1 class="text-2xl font-bold mb-2">Authorization Failed</h1>
<p class="text-gray-400 mb-4">${decodeURIComponent(error)}</p>
<p class="text-gray-500 text-sm">Redirecting to home...</p>
</div>
`;
setTimeout(() => {
window.location.href = 'index.html';
}, 3000);
} else if (accessToken) {
// Store token in localStorage
localStorage.setItem('spotify_access_token', accessToken);
// Redirect back to main app
window.location.href = 'index.html?authorized=true';
} else {
// No token or error found
document.body.innerHTML = `
<div class="text-center">
<div class="text-6xl mb-4">⚠️</div>
<h1 class="text-2xl font-bold mb-2">Authorization Error</h1>
<p class="text-gray-400 mb-4">No authorization code received</p>
<p class="text-gray-500 text-sm">Redirecting to home...</p>
</div>
`;
setTimeout(() => {
window.location.href = 'index.html';
}, 3000);
}
</script>
</body>
</html>