Skip to main content

Android Managed API Service

Functions

syncManagedAPIs

suspend fun syncManagedAPIs(context: Context): Result<Unit>

Synchronizes Managed APIs metadata with the Orchestrator and updates local storage.

Parameters:

  • context: Context — Android context.

syncManagedAPIs

fun syncManagedAPIs(
context: Context,
onSuccess: () -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit

Synchronizes Managed APIs metadata with the Orchestrator and updates local storage.

Parameters:

  • context: Context — Android context.
  • onSuccess: () -> Unit — Called when the sync operation completes successfully.
  • onError: ((Throwable) -> Unit)? — Called if the sync operation fails.

getManagedAPIs

suspend fun getManagedAPIs(context: Context)

Returns all Managed API definitions currently stored on the device.

Parameters:

  • context: Context — Android context.

getManagedAPIs

fun getManagedAPIs(
context: Context,
onSuccess: (List<DataMap>) -> Unit,
onError: ((Throwable) -> Unit)? = null
)

Returns all Managed API definitions currently stored on the device.

Parameters:

  • context: Context — Android context.
  • onSuccess: (List) -> Unit — Called with the full list of Managed APIs.
  • onError: ((Throwable) -> Unit)? — Called if the operation fails.

getManagedAPI

suspend fun getManagedAPI(
context: Context,
name: String
)

Retrieves a single Managed API definition by its name. Returns null if it does not exist.

Parameters:

  • context: Context — Android context.
  • name: String — Programmatic name of the Managed API.

getManagedAPI

fun getManagedAPI(
context: Context,
name: String,
onSuccess: (DataMap?) -> Unit,
onError: ((Throwable) -> Unit)? = null
)

Retrieves a single Managed API definition by its name. Returns null if it does not exist.

Parameters:

  • context: Context — Android context.
  • name: String — Programmatic name of the Managed API.
  • onSuccess: (DataMap?) -> Unit — Called with the Managed API definition or null.
  • onError: ((Throwable) -> Unit)? — Called if the operation fails.

startOAuth

suspend fun startOAuth(
context: Context,
authUrl: String,
redirectUri: String,
queryName: String = "access_token"
)

Starts an OAuth authentication flow using an in-app browser and returns the authorization code extracted from the redirect URL.

Parameters:

  • context: Context — Android context.
  • authUrl: String — Authorization endpoint URL.
  • redirectUri: String — Redirect URI that will receive the authorization code.
  • queryName: String — Query parameter name that contains the authorization code.

startOAuth

fun startOAuth(
context: Context,
authUrl: String,
redirectUri: String,
queryName: String = "access_token",
callback: (code: String) -> Unit
)

Starts an OAuth authentication flow using an in-app browser and returns the authorization code extracted from the redirect URL.

Parameters:

  • context: Context — Android context.
  • authUrl: String — Authorization endpoint URL.
  • redirectUri: String — Redirect URI that will receive the authorization code.
  • queryName: String — Query parameter name that contains the authorization code.
  • callback: (code: String) -> Unit — Called with the extracted authorization code.

fetchTokenFromCode

suspend fun fetchTokenFromCode(
tokenUrl: String,
httpMethod: String = "POST"
)

Exchanges an OAuth authorization code for an access token using the given token endpoint.

Parameters:

  • tokenUrl: String — Token endpoint URL.
  • httpMethod: String — HTTP method to use (must be GET or POST).

fetchTokenFromCode

fun fetchTokenFromCode(
tokenUrl: String,
httpMethod: String = "POST",
onSuccess: (response: String) -> Unit,
onError: ((Throwable) -> Unit)? = null
)

Exchanges an OAuth authorization code for an access token using the given token endpoint.

Parameters:

  • tokenUrl: String — Token endpoint URL.
  • httpMethod: String — HTTP method to use (must be GET or POST).
  • onSuccess: (response: String) -> Unit — Called with the raw token response or access token string.
  • onError: ((Throwable) -> Unit)? — Called if the token request fails.

Classes

DataMap

typealias DataMap = Map<String, String>