• AuthCore
  • AuthCore Class

    Handles the low-level OAuth2 logic for user authentication. More...

    Header: #include <AuthCore>
    Inherits: QObject

    Public Functions

    AuthCore(QObject *parent = nullptr)
    void cancelAuthenticationFlow()
    void checkHealth(const QUrl &url, AuthCore::HealthCheckCallback callback)
    void startAuthenticationFlow(const DiscoveryPayload &payload, AuthCore::AuthenticationCallback callback)

    Detailed Description

    AuthCore wraps the Qt OAuth2 framework to drive user authentication via the OAuth2 authorization code flow. It handles URL redirection, token acquisition, and error propagation. It is intended to be used internally by a higher-level authentication manager.

    Internal Members

    The following private members and slots are internal mechanisms used by AuthCore and not exposed to higher-level components:

    Private Variables

    • m_authFlow (QOAuth2AuthorizationCodeFlow) – Manages the OAuth2 grant flow and token state.
    • m_replyHandler (QOAuthHttpServerReplyHandler) – Listens on localhost for redirect responses.
    • m_callback (AuthenticationCallback) – Function to invoke when authentication completes or fails.
    • m_networkManager (QNetworkAccessManager) – Used to perform a simple health check before authentication begins.

    Internal Slots

    • onAuthenticationUrlRequested() – Emits a signal to show the login page in a browser.
    • onGranted() – Called when an access token is received successfully.
    • onErrorOccurred() – Called when OAuth2 encounters an error.

    Member Function Documentation

    [explicit] AuthCore::AuthCore(QObject *parent = nullptr)

    Constructs the AuthCore instance.

    parent is the optional parent object.

    void AuthCore::cancelAuthenticationFlow()

    Cancels any in-progress authentication attempt and resets internal state.

    void AuthCore::checkHealth(const QUrl &url, AuthCore::HealthCheckCallback callback)

    Pings the given url and calls callback with the result.

    Used to ensure the authentication server is reachable before launching the login flow.

    void AuthCore::startAuthenticationFlow(const DiscoveryPayload &payload, AuthCore::AuthenticationCallback callback)

    Starts the OAuth2 authentication code flow using the provided payload and callback.

    This configures OAuth URLs, sets up a localhost reply handler, and begins the login process.