static withUserPrompt()

in packages/azure-kusto-data/src/connectionBuilder.browser.ts [80:114]


    static withUserPrompt(
        connectionString: string,
        interactiveCredentialOptions: InteractiveBrowserCredentialNodeOptions | InteractiveBrowserCredentialInBrowserOptions,
        timeoutMs?: number,
    ): KustoConnectionStringBuilder {
        if (!interactiveCredentialOptions) {
            throw new Error(
                "Invalid parameters - You must provide interactiveCredentialOptions={clientId: string, redirectUri:string} to authenticate with user prompt in browser.",
            );
        }
        const kcsb = new KustoConnectionStringBuilder(connectionString);
        const { redirectUri, clientId, tenantId } = interactiveCredentialOptions as InteractiveBrowserCredentialInBrowserOptions;
        if (!clientId) {
            throw new Error("Invalid parameters - You must provide your SPA application client id to authenticate against");
        }

        if (!redirectUri) {
            throw new Error("Invalid parameters - You must provide a redirectUri registered on the SPA app");
        }

        if (tenantId) {
            kcsb.authorityId = tenantId;
        } else {
            interactiveCredentialOptions.tenantId = kcsb.authorityId;
        }

        kcsb.interactiveCredentialOptions = interactiveCredentialOptions;
        kcsb.aadFederatedSecurity = true;
        kcsb.applicationClientId = clientId;
        kcsb.useUserPromptAuth = true;

        kcsb.timeoutMs = timeoutMs;

        return kcsb;
    }