Skip to content

Commit

Permalink
Create callback.html
Browse files Browse the repository at this point in the history
  • Loading branch information
pilot2254 authored Jan 5, 2025
1 parent db36f44 commit 32d4496
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions callback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Authenticating...</title>
<style>
body {
background: #0d1117;
color: #c9d1d9;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
</style>
</head>
<body>
<div id="status">Authenticating...</div>

<script>
async function handleCallback() {
const code = new URLSearchParams(window.location.search).get('code');

if (!code) {
window.location.href = './';
return;
}

try {
// Get user info to store
const userResponse = await fetch('https://api.github.com/user', {
headers: {
'Authorization': `Bearer ${code}`
}
});

const user = await userResponse.json();

// Store auth info
localStorage.setItem('github-chat-auth', JSON.stringify({
token: code,
user
}));

// Redirect back to main page
window.location.href = './';
} catch (error) {
console.error('Auth error:', error);
document.getElementById('status').textContent = 'Authentication failed. Please try again.';
}
}

handleCallback();
</script>
</body>
</html>

0 comments on commit 32d4496

Please sign in to comment.