A module representing users on Auth0
Summary
Functions
Gets all the users
Assigns permissions to a user directly.
Assigns roles to a user. Scopes: update:users
Gets a single authentication method
Lists a user's authentication methods — the factors they can log in with.
Finds users by email address.
Clears a user's risk assessments, so past signals stop influencing their next login.
Lists accounts the user has connected from other providers. Uses checkpoint pagination.
Creates a user for the specified connection
Adds an authentication method. type is required — phone, email, totp or
webauthn-roaming.
Deletes a user with a give user id
Deletes a single authentication method
Deletes all users MFA authentication methods. Scopes: delete:authentication_methods
Deletes all of a user's MFA authenticators, forcing re-enrollment
Deletes a user's multifactor provider
Deletes all of a user's refresh tokens. Answers 202.
Deletes all of a user's sessions, signing them out everywhere.
Lists the roles that grant a user a given permission, answering "why does this user have this permission?".
Lists every permission a user has, whether granted directly, through a role, or through a group.
Lists the groups that grant a user a given role, answering "why does this user have this role?".
Lists every role a user has, whether assigned directly or inherited through a group.
Gets the user's first confirmed Guardian MFA enrollment.
Gets a specific user record with a given user id
Lists the groups a user belongs to
Invalidates every remembered browser, so the user is prompted for MFA again
Links the account specified in the body to the given user_id param
Get a user's log
Lists the organizations a user belongs to. Scopes: read:users read:organizations
Lists the permissions granted to a user directly, ignoring any that come from a
role. Use effective_permissions/2 for the full picture. Scopes: read:users
Lists a user's refresh tokens. Uses checkpoint pagination.
Removes current Guardain recovery code and generates new one
Removes permissions from a user. Scopes: update:users
Removes roles from a user. Scopes: update:users
Replaces every authentication method the user has.
Revokes a user's access — sessions and refresh tokens together. Answers 202.
List the roles associated with a user. Scopes: read:users read:roles
Lists a user's active sessions. Uses checkpoint pagination.
Unlinks an identity from the target user, and it becomes a separated user again.
Updates a user's information given a user id
Updates an authentication method's name or preference
Functions
Gets all the users
Defaults to the v3 search engine, which is the only one Auth0 still supports. Pass
an explicit search_engine to override it.
v3 search differs from v2 in ways that silently return nothing rather than erroring:
.rawsub-fields are gone — query the field directlyconnectionbecameidentities.connectionmatching is case-sensitive
results cap at 1,000 records; use
Auth0Client.Management.Job.users_exports/1for anything largeriex> Auth0Client.Management.User.all() iex> Auth0Client.Management.User.all(fields: "name", q: "app_metadata.admin:'true'")
Assigns permissions to a user directly.
Accepts either the documented map form or {api_identifier, permission_name}
tuples. Scopes: update:users
iex> Auth0Client.Management.User.assign_permissions("auth0|23423", [{"https://api.example.com", "read:users"}])
Assigns roles to a user. Scopes: update:users
iex> Auth0Client.Management.User.assign_roles("auth0|23423", ["rol_abc123"])
Gets a single authentication method
iex> Auth0Client.Management.User.authentication_method("auth0|23423", "aum_1")
Lists a user's authentication methods — the factors they can log in with.
iex> Auth0Client.Management.User.authentication_methods("auth0|23423")
Finds users by email address.
This is an exact, case-insensitive match on the identity, and it is usually what
you want. all/1 goes through the v3 search engine instead, which is
case-sensitive and caps at 1,000 records — worth avoiding when you simply have an
address and want the user.
Returns a list, because one address can belong to several identities across connections.
iex> Auth0Client.Management.User.by_email("someone@example.com")
iex> Auth0Client.Management.User.by_email("someone@example.com", fields: "user_id,email")
Clears a user's risk assessments, so past signals stop influencing their next login.
iex> Auth0Client.Management.User.clear_risk_assessments("auth0|23423")
iex> Auth0Client.Management.User.clear_risk_assessments("auth0|23423", %{assessors: ["NewDevice"]})
Lists accounts the user has connected from other providers. Uses checkpoint pagination.
iex> Auth0Client.Management.User.connected_accounts("auth0|23423")
Creates a user for the specified connection
iex> Auth0Client.Management.User.create("test_connection", %{email: "test.user@email.com", username: "test_user_name"})
Adds an authentication method. type is required — phone, email, totp or
webauthn-roaming.
iex> Auth0Client.Management.User.create_authentication_method("auth0|23423", %{type: "totp", totp_secret: "..."})
Deletes a user with a give user id
iex> Auth0Client.Management.User.delete("auth0|some_user_id")
Deletes a single authentication method
iex> Auth0Client.Management.User.delete_authentication_method("auth0|23423", "aum_1")
Deletes all users MFA authentication methods. Scopes: delete:authentication_methods
iex > Auth0Client.Management.User.delete_authentication_methods("auth0|23423")
Deletes all of a user's MFA authenticators, forcing re-enrollment
iex> Auth0Client.Management.User.delete_authenticators("auth0|23423")
Deletes a user's multifactor provider
iex> Auth0Client.Management.User.delete_mfprovider("auth0|23423", "duo")
Deletes all of a user's refresh tokens. Answers 202.
iex> Auth0Client.Management.User.delete_refresh_tokens("auth0|23423")
Deletes all of a user's sessions, signing them out everywhere.
Auth0 accepts this asynchronously and answers 202.
iex> Auth0Client.Management.User.delete_sessions("auth0|23423")
Lists the roles that grant a user a given permission, answering "why does this user have this permission?".
Pass resource_server_identifier and permission_name to name the permission.
iex> Auth0Client.Management.User.effective_permission_source_roles("auth0|23423", resource_server_identifier: "https://api.example.com", permission_name: "read:users")
Lists every permission a user has, whether granted directly, through a role, or through a group.
Pass resource_server_identifier to limit it to one API. Uses checkpoint
pagination — from and take.
iex> Auth0Client.Management.User.effective_permissions("auth0|23423")
iex> Auth0Client.Management.User.effective_permissions("auth0|23423", resource_server_identifier: "https://api.example.com")
Lists the groups that grant a user a given role, answering "why does this user have this role?".
Pass role_id to narrow it to one role.
iex> Auth0Client.Management.User.effective_role_source_groups("auth0|23423", role_id: "rol_abc123")
Lists every role a user has, whether assigned directly or inherited through a group.
roles/2 reports only direct assignments, so a user who gets their access
through a group looks role-less to it. Use this when you need the truth.
Uses checkpoint pagination — from and take. Scopes: read:users read:roles
iex> Auth0Client.Management.User.effective_roles("auth0|23423")
Gets the user's first confirmed Guardian MFA enrollment.
Auth0 returns only the first confirmed enrollment here, not every enrollment the user has.
iex> Auth0Client.Management.User.enrollments("auth0|234")
Gets a specific user record with a given user id
iex> Auth0Client.Management.User.get("auth0|some_user_id")
iex> Auth0Client.Management.User.get("auth0|some_user_id", %{fields: "email,name,username"})
Lists the groups a user belongs to
iex> Auth0Client.Management.User.groups("auth0|23423")
Invalidates every remembered browser, so the user is prompted for MFA again
iex> Auth0Client.Management.User.invalidate_remember_browser("auth0|23423")
Links the account specified in the body to the given user_id param
iex> Auth0Client.Management.User.link("some_user_id", link_with: "secondary_acc_jwt")
iex> Auth0Client.Management.User.link("some_user_id", provider: "github", user_id: "23423", connection_id: "som")
Get a user's log
iex> Auth0Client.Management.User.log("auth0|233423")
iex> Auth0Client.Management.User.log("auth0|23423", page: 2, per_page: 10)
Lists the organizations a user belongs to. Scopes: read:users read:organizations
iex> Auth0Client.Management.User.organizations("auth0|23423")
Lists the permissions granted to a user directly, ignoring any that come from a
role. Use effective_permissions/2 for the full picture. Scopes: read:users
iex> Auth0Client.Management.User.permissions("auth0|23423")
Lists a user's refresh tokens. Uses checkpoint pagination.
iex> Auth0Client.Management.User.refresh_tokens("auth0|23423")
Removes current Guardain recovery code and generates new one
iex> Auth0Client.Management.User.regenerate_recovery_code("auth0|34234")
Removes permissions from a user. Scopes: update:users
iex> Auth0Client.Management.User.remove_permissions("auth0|23423", [{"https://api.example.com", "read:users"}])
Removes roles from a user. Scopes: update:users
iex> Auth0Client.Management.User.remove_roles("auth0|23423", ["rol_abc123"])
Replaces every authentication method the user has.
The body is a bare list, not an object wrapping one, and anything absent from it is removed.
iex> Auth0Client.Management.User.replace_authentication_methods("auth0|23423", [%{type: "email", email: "a@b.com"}])
Revokes a user's access — sessions and refresh tokens together. Answers 202.
session_id limits it to one session; preserve_refresh_tokens keeps the
refresh tokens alive.
iex> Auth0Client.Management.User.revoke_access("auth0|23423")
iex> Auth0Client.Management.User.revoke_access("auth0|23423", %{preserve_refresh_tokens: true})
List the roles associated with a user. Scopes: read:users read:roles
iex > Auth0Client.Management.User.roles("auth0|23423")
Lists a user's active sessions. Uses checkpoint pagination.
iex> Auth0Client.Management.User.sessions("auth0|23423")
Unlinks an identity from the target user, and it becomes a separated user again.
iex> Auth0Client.Management.User.unlink("some_user_id", "github", "23984234")
Updates a user's information given a user id
iex> Auth0Client.Management.User.update("auth0|some_user_id", %{app_metadata: %{admin: false}})
Updates an authentication method's name or preference
iex> Auth0Client.Management.User.update_authentication_method("auth0|23423", "aum_1", %{name: "Work phone"})