Merge pull request #573 from seidnerj/fix/oauth-response-pages

fix: improve OAuth response pages for browser compatibility
This commit is contained in:
Taylor Wilsdon
2026-03-17 11:49:10 -04:00
committed by GitHub

View File

@@ -26,8 +26,7 @@ def create_error_response(error_message: str, status_code: int = 400) -> HTMLRes
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 40px auto; padding: 20px; text-align: center;"> <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 40px auto; padding: 20px; text-align: center;">
<h2 style="color: #d32f2f;">Authentication Error</h2> <h2 style="color: #d32f2f;">Authentication Error</h2>
<p>{error_message}</p> <p>{error_message}</p>
<p>Please ensure you grant the requested permissions. You can close this window and try again.</p> <p>Please ensure you grant the requested permissions. You can close this tab and try again.</p>
<script>setTimeout(function() {{ window.close(); }}, 10000);</script>
</body> </body>
</html> </html>
""" """
@@ -176,9 +175,17 @@ def create_success_response(verified_user_id: Optional[str] = None) -> HTMLRespo
}} }}
</style> </style>
<script> <script>
setTimeout(function() {{ function tryClose() {{
window.close(); window.close();
}}, 10000); // If window.close() was blocked by the browser, update the UI
setTimeout(function() {{
var btn = document.querySelector('.button');
if (btn) btn.textContent = 'You can close this tab manually';
var ac = document.querySelector('.auto-close');
if (ac) ac.style.display = 'none';
}}, 500);
}}
setTimeout(tryClose, 10000);
</script> </script>
</head> </head>
<body> <body>
@@ -189,10 +196,10 @@ def create_success_response(verified_user_id: Optional[str] = None) -> HTMLRespo
You've been authenticated as <span class="user-id">{user_display}</span> You've been authenticated as <span class="user-id">{user_display}</span>
</div> </div>
<div class="message"> <div class="message">
Your credentials have been securely saved. You can now close this window and retry your original command. Your credentials have been securely saved. You can now close this tab and retry your original command.
</div> </div>
<button class="button" onclick="window.close()">Close Window</button> <button class="button" onclick="tryClose()">Close Tab</button>
<div class="auto-close">This window will close automatically in 10 seconds</div> <div class="auto-close">This tab will close automatically in 10 seconds</div>
</div> </div>
</body> </body>
</html>""" </html>"""
@@ -215,8 +222,7 @@ def create_server_error_response(error_detail: str) -> HTMLResponse:
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 40px auto; padding: 20px; text-align: center;"> <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 600px; margin: 40px auto; padding: 20px; text-align: center;">
<h2 style="color: #d32f2f;">Authentication Processing Error</h2> <h2 style="color: #d32f2f;">Authentication Processing Error</h2>
<p>An unexpected error occurred while processing your authentication: {error_detail}</p> <p>An unexpected error occurred while processing your authentication: {error_detail}</p>
<p>Please try again. You can close this window.</p> <p>Please try again. You can close this tab.</p>
<script>setTimeout(function() {{ window.close(); }}, 10000);</script>
</body> </body>
</html> </html>
""" """