Overview
This article provides an example on how to perform user searches using the go-auth0 SDK.
Applies To
- GoLang
- Go
- Go-auth0
- User Search
Solution
Initialize the Management Client as per the documentation:
The query can be wrapped in backticks (`) to allow for quotation marks (") within the Lucene Query syntax.
e
.g.
auth0API, err := management.New(
domain,
management.WithClientCredentials(context.TODO(), clientID, clientSecret), // Replace with a Context that better suits your usage
)
if err != nil {
log.Fatalf("failed to initialize the auth0 management API client: %+v", err)
}
// Now we can interact with the Auth0 Management API.
users, err := auth0API.User.List(
context.Background(),
//management.Query(`email.domain:"example.com"`), // example search by email domain
management.Query(`phone_number:"+1234567890" AND identities.connection:"sms"`), // example search with boolean logic
management.PerPage(5), // Get 5 users per page
management.IncludeTotals(true),
Please note that not all attributes on the user profile are searchable. For more details on the user search query syntax, see the documentation here: