Auth0Client.Management.Client (auth0_client v1.0.0)

Copy Markdown View Source

A module representing clients — applications — on Auth0.

Beyond the application itself, this covers client credentials: the public keys and certificates that let an application authenticate with Private Key JWT or mTLS instead of a shared secret. Registering one is two steps, and the second is easy to miss — see create_credential/2.

https://auth0.com/docs/api/management/v2/clients

Summary

Functions

Gets all the clients

Lists the connections enabled for a client.

Creates a new Auth0 client from given body

Registers a credential for Private Key JWT or mTLS authentication.

Gets one client credential

Lists a client's credentials

Deletes the client with given client id

Deletes a client credential.

Gets the information for individual client

Validates a Client ID Metadata Document (CIMD) without creating anything.

Registers or updates an application from a Client ID Metadata Document (CIMD).

Rotate a client secret for client with given ID

Updates Auth0 client of given ID with given body

Updates a client credential.

Functions

all(params \\ %{})

Gets all the clients

Searching with q needs checkpoint pagination — pass from and take rather than page — and carries lower rate limits than an unfiltered listing.

iex> Auth0Client.Management.Client.all()
iex> Auth0Client.Management.Client.all(fields: "name,client_id")
iex> Auth0Client.Management.Client.all(q: "name:acme*", take: 50)

connections(id, params \\ %{})

Lists the connections enabled for a client.

Filter by strategy; supports checkpoint pagination with from and take.

iex> Auth0Client.Management.Client.connections("some_client_id")
iex> Auth0Client.Management.Client.connections("some_client_id", strategy: "auth0")

create(body)

Creates a new Auth0 client from given body

iex> Auth0Client.Management.Client.create(%{name: "Samars App"})

create_credential(id, body)

Registers a credential for Private Key JWT or mTLS authentication.

credential_type is required — "public_key" for Private Key JWT, "cert_subject_dn" or "x509_cert" for mTLS. A public key also takes pem and alg (RS256, RS384 or PS256).

Registering a credential does not enable it

Auth0 will not use the credential until the application says it should. Follow this with update/2, setting client_authentication_methods — until then the credential exists and does nothing.

iex> Auth0Client.Management.Client.create_credential("some_client_id", %{
...>   credential_type: "public_key",
...>   name: "Deploy key",
...>   pem: "-----BEGIN PUBLIC KEY-----...",
...>   alg: "RS256"
...> })

credential(id, credential_id)

Gets one client credential

iex> Auth0Client.Management.Client.credential("some_client_id", "cred_abc123")

credentials(id)

Lists a client's credentials

iex> Auth0Client.Management.Client.credentials("some_client_id")

delete(id)

Deletes the client with given client id

iex> Auth0Client.Management.Client.delete("some_client_id")

delete_credential(id, credential_id)

Deletes a client credential.

If the application still lists it in client_authentication_methods, it can no longer authenticate — remove it there first.

iex> Auth0Client.Management.Client.delete_credential("some_client_id", "cred_abc123")

get(id)

Gets the information for individual client

iex> Auth0Client.Management.Client.get("some_id")
iex> Auth0Client.Management.Client.get("some_id", [fields: "id,client_id", include_fields: true])

get(id, params)

preview_metadata_document(body)

Validates a Client ID Metadata Document (CIMD) without creating anything.

Fetches the document and reports how its fields would map onto an Auth0 application. Useful for checking a document before registering it.

iex> Auth0Client.Management.Client.preview_metadata_document(%{external_client_id: "https://app.example.com/metadata"})

register_metadata_document(body)

Registers or updates an application from a Client ID Metadata Document (CIMD).

Idempotent, keyed on external_client_id: Auth0 answers 201 when it creates the application and 200 when it updates an existing one. Both are success, and this library returns {:ok, client} either way.

iex> Auth0Client.Management.Client.register_metadata_document(%{external_client_id: "https://app.example.com/metadata"})

rotate_secret(id)

Rotate a client secret for client with given ID

iex> Auth0Client.Management.Client.rotate_secret("some_client_id")

update(id, body)

Updates Auth0 client of given ID with given body

iex> Auth0Client.Management.Client.update("some_client_id", %{name: "New Client Name"})

update_credential(id, credential_id, body)

Updates a client credential.

Only expires_at can change; everything else is fixed at creation. Auth0 answers this PATCH with 201 rather than 200.

iex> Auth0Client.Management.Client.update_credential("some_client_id", "cred_abc123", %{expires_at: "2027-01-01T00:00:00Z"})