0

I am trying to create a GSuite integration using GSuite Admin SDK that will fetch a list of users and the datetime of their last activity. I am able to fetch last login time, but I can't find a way to find the last email activity for a user that uses POP or IMAP email clients.

The data that I am trying to fetch is available in the admin console:

enter image description here

But is there a way to fetch it using Gsuite Admin SDK?

shtrule
  • 658
  • 10
  • 23
  • To retrieve all user usage activities you can refer to the [documentation](https://developers.google.com/admin-sdk/reports/v1/guides/manage-usage-users#get_all_user_usage). Use the `GET` HTTP request specified in the documentation and include the authorization token described in the [authorization documentation](https://developers.google.com/admin-sdk/reports/v1/guides/authorizing.html). – MαπμQμαπkγVπ.0 May 25 '18 at 09:22

1 Answers1

0

I found a solution to get the email activities for users, but the examples in the API reference were not so straight-forward, and they were spread out on several pages. I ended up using User Usage Report from the GSuite Reports API (as suggested in a comment on the original question): https://developers.google.com/admin-sdk/reports/v1/guides/manage-usage-users

Sample call:

GET https://www.googleapis.com/admin/reports/v1/usage/users/all/dates/2018-05-21?parameters=classroom:last_interaction_time,accounts:last_login_time,accounts:last_sso_time,gmail:last_access_time,gmail:last_imap_time,gmail:last_interaction_time,gmail:last_pop_time,gmail:last_webmail_time  

This way I was able to get not only email activities, but also Classroom last interaction time and GSuite last login time and Last SSO time.

Sample user response:

        "entity": {
            "type": "USER",
            "customerId": "customerId",
            "userEmail": "sample@email.com",
            "profileId": "profileId"
        },
        "parameters": [
            {
                "name": "classroom:last_interaction_time",
                "datetimeValue": "1970-01-01T00:00:00.000Z"
            },
            {
                "name": "accounts:last_login_time",
                "datetimeValue": "2018-05-18T14:46:11.000Z"
            },
            {
                "name": "accounts:last_sso_time",
                "datetimeValue": "1970-01-01T00:00:00.000Z"
            },
            {
                "name": "gmail:last_access_time",
                "datetimeValue": "2018-05-18T08:43:15.000Z"
            },
            {
                "name": "gmail:last_imap_time",
                "datetimeValue": "1970-01-01T00:00:00.000Z"
            },
            {
                "name": "gmail:last_interaction_time",
                "datetimeValue": "2018-04-23T07:08:40.000Z"
            },
            {
                "name": "gmail:last_pop_time",
                "datetimeValue": "1970-01-01T00:00:00.000Z"
            },
            {
                "name": "gmail:last_webmail_time",
                "datetimeValue": "2018-04-23T07:08:44.000Z"
            }
        ]
shtrule
  • 658
  • 10
  • 23