I'd like to know when a given user last logged in. It seems that the User object doesn't include this information (creation and modification only). Should I look to leverage the Events API (seems inefficient) or am I missing something obvious?
Yes, look to the Events API for this. Specifically, you'll want to use the Enterprise Events API and query for events of the type LOGIN
. This requires an access token with administrative privileges.
curl https://api.box.com/2.0/events?stream_type=admin_logs&event_type=LOGIN \
-H "Authorization: Bearer ACCESS_TOKEN"
Note that:
created_after
and created_before
query parameters to limit the returned events to a specific time period.FAILED_LOGIN
events: event_type=LOGIN,FAILED_LOGIN