oauth-callback.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Connecting...</title>
  6. <script src="https://cdn.tailwindcss.com"></script>
  7. <style>
  8. @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
  9. .spinner { border-top-color: #3b82f6; animation: spin 1s linear infinite; }
  10. </style>
  11. </head>
  12. <body class="bg-slate-100 flex items-center justify-center min-h-screen">
  13. <div class="text-center p-8 bg-white rounded-lg shadow-md">
  14. <div class="spinner w-12 h-12 border-4 border-slate-200 rounded-full mx-auto mb-4"></div>
  15. <h1 class="text-xl font-semibold text-slate-700">Finalizing Connection...</h1>
  16. <p class="text-slate-500 mt-2">Please wait while we verify your account.</p>
  17. </div>
  18. <script>
  19. window.onload = () => {
  20. const params = new URLSearchParams(window.location.search);
  21. const code = params.get('code');
  22. const error = params.get('error');
  23. const platform = params.get('state'); // Real OAuth providers use 'state' to return context
  24. if (window.opener) {
  25. if (code && platform) {
  26. // In a real app, the backend would use this `code` to get an access token and user info.
  27. // Here, we'll simulate success and create a placeholder profile URL.
  28. const username = 'verified.user';
  29. const profileUrls = {
  30. linkedin: `https://www.linkedin.com/in/${username}`,
  31. x: `https://x.com/${username}`,
  32. github: `https://github.com/${username}`,
  33. tiktok: `https://www.tiktok.com/@${username}`,
  34. instagram: `https://www.instagram.com/${username}`,
  35. facebook: `https://www.facebook.com/${username}`,
  36. discord: `VerifiedUser#1234`
  37. };
  38. const message = {
  39. type: 'oauth-success',
  40. platform: platform,
  41. profileUrl: profileUrls[platform] || `https://example.com/${username}`
  42. };
  43. window.opener.postMessage(message, window.location.origin);
  44. } else {
  45. // Handle failure
  46. const message = {
  47. type: 'oauth-error',
  48. platform: platform,
  49. error: error || 'Authentication failed or was cancelled by the user.'
  50. };
  51. window.opener.postMessage(message, window.location.origin);
  52. }
  53. }
  54. // Close the popup after a short delay to allow the message to be sent
  55. setTimeout(() => window.close(), 500);
  56. };
  57. </script>
  58. </body>
  59. </html>