How to retrieve previous login time for all users?

I need to write some code that will produce a report of when each user last logged in. In other words, something similar to what is shown when an administrator browses the list of users.

Looking at the REST API documentation, I can see that previousLoginTime is returned from the auth/1/session calls but these only apply to the currently authenticated user. I cannot find a method in the REST API that allows me to retrieve that information for a specific user.

Can this be done through the API?

I think you are correct: there’s no REST API for obtaining the login info for a given user, other than the current user. It would be a small thing, though, to write an add-on that provides such a REST end-point. That add-on would use an instance of com.atlassian.jira.bc.security.login.LoginService, which provides a getLoginInfo(String userName) method.

2 Likes

Thanks, David.

Unfortunately, writing that is beyond my capabilities. I guess that, without an API, I’ll have to try and find it in the database, which is far from ideal but manageable for me at least.

Are there any API call exist now?
any plugins might provide this? We have so many active users in our jira instance who logged in minimal times in past few years and counting against expensive jira user seats, need to clean them up.
Any help much appreciated.

1 Like

Yes, is there a way to request the api to get users last login, another use case is to ensure former users/employees are still not logging in.