首页 > 解决方案 > GSuite - 上次电子邮件活动

问题描述

我正在尝试使用 GSuite Admin SDK 创建一个 GSuite 集成,它将获取用户列表和他们上次活动的日期时间。我能够获取上次登录时间,但我找不到使用 POP 或 IMAP 电子邮件客户端的用户查找上次电子邮件活动的方法。

我试图获取的数据在管理控制台中可用:

在此处输入图像描述

但是有没有办法使用 Gsuite Admin SDK 来获取它?

标签: google-admin-sdkgoogle-workspace

解决方案


我找到了一个为用户获取电子邮件活动的解决方案,但 API 参考中的示例并不那么简单,它们分散在几个页面上。我最终使用了 GSuite Reports API 中的用户使用情况报告(如对原始问题的评论中所建议):https ://developers.google.com/admin-sdk/reports/v1/guides/manage-usage-users

示例调用:

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  

通过这种方式,我不仅可以获得电子邮件活动,还可以获得 Classroom 上次交互时间和 GSuite 上次登录时间和上次 SSO 时间。

示例用户响应:

        "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"
            }
        ]

推荐阅读