Client for the Kinde Management API.
Starts as a GenServer under the application supervisor and automatically obtains and renews an access token using the client credentials flow.
Configuration
config :kinde, :management_api,
client_id: "management_client_id",
client_secret: "management_client_secret",
business_domain: "https://yourapp.kinde.com" # defaults to :domainIf :business_domain is not set, the top-level :domain config value is used.
The server returns :ignore on startup when required keys are missing, so the
application can still boot without Management API credentials.
Summary
Functions
Returns a specification to start this module under a supervisor.
Deletes all MFA settings for a user.
Fetches a user by their Kinde ID.
Fetches all users, handling pagination automatically.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec delete_mfa(String.t(), GenServer.server()) :: :ok | {:error, term()}
Deletes all MFA settings for a user.
Returns :ok on success, {:error, %APIError{}} on API errors,
or {:error, %NoAccessTokenError{}} if the access token hasn't been obtained yet.
Examples
iex> Kinde.ManagementAPI.delete_mfa("kp_abc123def456")
:ok
@spec get_user(String.t(), GenServer.server()) :: {:ok, map()} | {:error, term()}
Fetches a user by their Kinde ID.
Returns {:ok, user_map} on success, {:error, %APIError{}} on API errors,
or {:error, %NoAccessTokenError{}} if the access token hasn't been obtained yet.
Examples
iex> Kinde.ManagementAPI.get_user("kp_abc123def456")
{:ok, %{"first_name" => "Mary", "last_name" => "Doe", ...}}
@spec list_users(GenServer.server()) :: {:ok, [map()]} | {:error, term()}
Fetches all users, handling pagination automatically.
Returns {:ok, [user_map]} with a flat list of all users across all pages.
Examples
iex> Kinde.ManagementAPI.list_users()
{:ok, [%{"first_name" => "John", ...}, %{"first_name" => "Jane", ...}]}