Does okta gives last login history?

Do we have service to fetch last 10 login time ?

1 Like

You can get information about logins by querying the system log, either on the Admin console or via API, For example, this request will get the last 10 successful logins for your org:

{{url}}/api/v1/logs?filter=eventType eq "user.session.start" and outcome.result eq "SUCCESS"&limit=10

You can also modify the filter to narrow it down by a specific user:
{{url}}/api/v1/logs?filter=eventType eq "user.session.start" and outcome.result eq "SUCCESS" and eq "{{userId}}"&limit=10

@andreaskouras Thanks for the api but we are getting event time in this

Slight tweak to the request, as the logs endpoint defaults to sorting results in ascending order (unlike if you were to use the filter within System Log on the Admin console), means you’ll want to do something more like this:
{{url}}/api/v1/logs?filter=eventType eq "user.session.start" and outcome.result eq "SUCCESS"&sortOrder=DESCENDING

This change results in the events in the response to be ordered by the ‘published’ DT that indicates when the event occurred

@andreaskouras thanks you very much.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.