Spaces:
Paused
Paused
File size: 3,104 Bytes
44ebcd1 |
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 |
<!DOCTYPE html>
<html>
<head>
<title>Completing Authentication...</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f5f5f5;
}
.container {
text-align: center;
padding: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.spinner {
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 20px auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="container">
<h2>Completing authentication...</h2>
<div class="spinner"></div>
<p id="status">Please wait...</p>
</div>
<script>
function updateStatus(message) {
document.getElementById('status').textContent = message;
}
try {
// Extract token from URL
let token = null;
// For Google and Microsoft (token in hash)
if (window.location.hash) {
const hashParams = new URLSearchParams(window.location.hash.substring(1));
token = hashParams.get('access_token');
}
// For Slack (token might be in query params)
if (!token && window.location.search) {
const queryParams = new URLSearchParams(window.location.search);
token = queryParams.get('access_token');
// Slack might return a code instead of token
const code = queryParams.get('code');
if (code && !token) {
updateStatus('Slack requires additional setup. Please implement code exchange.');
setTimeout(() => {
if (window.opener) {
window.opener.postMessage({ type: 'auth-failed', error: 'Slack code exchange not implemented' }, '*');
window.close();
}
}, 3000);
}
}
if (token) {
updateStatus('Authentication successful! Closing window...');
// Send token back to parent window
if (window.opener) {
window.opener.postMessage({
type: 'auth-success',
token: token
}, window.location.origin);
// Close window after a short delay
setTimeout(() => window.close(), 1000);
} else {
updateStatus('Unable to communicate with main window. Please close this window manually.');
}
} else {
updateStatus('Authentication failed. No token received.');
setTimeout(() => {
if (window.opener) {
window.opener.postMessage({ type: 'auth-failed', error: 'No token received' }, '*');
window.close();
}
}, 3000);
}
} catch (error) {
updateStatus('An error occurred: ' + error.message);
console.error('Auth error:', error);
}
</script>
</body>
</html> |