I am trying to retrieve the most recent successful logins of a user, annotated with the geographic location where the user logged in from, preferably in a way I can get easily paginated. All the functionality appears to exist, but not in one place. I run into the following problems:
-
https://auth0.com/docs/api/management/v2#!/Users/get_logs_by_user (i.e.
/api/v2/users/{user_id}/logs
) allows me to get the events of a user and their location, but not to filter by event type to just successful logins. Get user logs by type suggests using the general/api/v2/logs
endpoint. However… -
https://auth0.com/docs/api/management/v2#!/Logs/get_logs (i.e.
/api/v2/logs
) allows me to filter by user and event type usingq=user_id:... AND type:s
but does not return location_info fields. About location_info inside the log object suggests that I can only retrieve location_info using the/api/v2/users/{user_id}/logs
above. - Even if I tried to augment above with individual calls to Auth0 Management API v2 this endpoint does not return location_info either (and even if possibly here, I could easily hit API rate limits).
My solutions seem to be:
- Use the
/api/v2/users/{user_id}/logs
endpoint, and manually filter bytype=="s"
. However, this breaks any reasonable attempts at pagination of results (so that a script/UI I build on top of this can get the next logins) and/or requires me to manually use Auth0’s pagination to find sufficient number of “type:s” entries intermingled with other user logs (e.g. if I’m trying to get the last 5 successful logins, I may have to go through many pages if many other operations occurred in between). - Use the undocumented ability for the
/api/v2/users/{user_id}/logs
endpoint to takeq=type:s
as a parameter. This is exactly the functionality I want, and this apparently works already (I tried it by modifying a call to curl to add this query parameter). However this is not documented in the API docs for v2, nor is it supported in the official Auth0 Python client. I see Migrate to Tenant Log Search v3 makes reference to a q field possibility for/api/v2/users/{user_id}/logs
, but it’s unclear if that was only available in v2.
So my questions are…
- Is there any plan to official support the Lucene query string parameter (as documented in Log Search Query Syntax) for the
/api/v2/users/{user_id}/logs
endpoint? - Is there any way to populate the location_info field if using the
/api/v2/logs
endpoint? - Or am I stuck manually paginating through every kind of user log just to extract fields of type:s to get both pieces of info at the same time?
(I know a longer term solution would involve us streaming the logs and performing the queries on our own indexes, but the pieces already seem to be there on Auth0’s side without us having to set up our own infrastructure for this.)