nat.front_ends.fastapi.html_snippets.auth_code_grant_error#

Attributes#

Functions#

build_auth_redirect_error_html(→ str)

Build the redirect-based authentication error HTML page.

Module Contents#

AUTH_REDIRECT_ERROR_HTML = Multiline-String#
Show Value
"""
<!DOCTYPE html>
<html>
<head>
    <title>Authentication Error</title>
    <script>
        (function () {
            window.history.replaceState(null, "", window.location.pathname);

            window.opener?.postMessage({ type: 'AUTH_ERROR' }, '*');

            window.close();
        })();
    </script>
</head>
<body>
    <p>Authentication failed. You may now close this window.</p>
</body>
</html>
"""
_AUTH_REDIRECT_ERROR_HTML_TEMPLATE = Multiline-String#
Show Value
"""<!DOCTYPE html>
<html>
<head>
    <title>Authentication Error</title>
    <script>
        (function () {
            var returnTo = RETURN_URL_PLACEHOLDER;
            if (returnTo) {
                window.location.replace(returnTo);
            } else {
                window.history.back();
            }
        })();
    </script>
</head>
<body>
    <p>Authentication failed. Redirecting&hellip;</p>
</body>
</html>
"""
build_auth_redirect_error_html(return_url: str | None = None) → str#

Build the redirect-based authentication error HTML page.

Navigates back to the UI without the oauth_auth_completed query parameter so the UI’s error-message branch handles it.

Args:
return_url: The UI origin to navigate back to. Falls back to

window.history.back() when not provided.

Returns:

An HTML string for the post-error redirect page.