installAuth

expect fun installAuth(config: HttpClientConfig<*>, baseUrl: String, authTokenProvider: suspend () -> String?? = null)

Function to configure the authentication for an HTTP client.

If an authTokenProvider is given, both implementations use the provided token for Bearer authentication. This is stateless.

If no authTokenProvider is given, the JS implementation does not configure authentication. If no authTokenProvider is given, the JVM implementation setups a server to perform an OAuth authorization code flow with PKCE. This makes many assumptions about the model server deployment, Keycloak deployment, Keycloak configuration, and the client. The PKCE is hard coded to work for MPS instances inside Modelix workspaces. This is stateful.

Parameters

config

Config for the HTTP client to be created. This config will be modified to enable authentication.

baseUrl

Base url of model server. Required for PKCE flow in JVM.

authTokenProvider

This function will be used to initially get an auth token and to refresh it when the old one expired. Returning null cause the client to attempt the request without a token.

actual fun installAuth(config: HttpClientConfig<*>, baseUrl: String, authTokenProvider: suspend () -> String??)
actual fun installAuth(config: HttpClientConfig<*>, baseUrl: String, authTokenProvider: suspend () -> String??)