Reputation: 1
I am trying to have last logins of a user in google platform using script.google.com but when I try with this sample: https://github.com/googleworkspace/apps-script-samples/blob/main/adminSDK/reports/quickstart.gs I only get old data. I have seen that there is much lag time for this event: https://apps.google.com/supportwidget/articlehome?hl=en&article_url=https%3A%2F%2Fsupport.google.com%2Fa%2Fanswer%2F7061566%3Fhl%3Den&assistant_id=generic-unu&product_context=7061566&product_name=UnuFlow&trigger_context=a
Anybody knows any way to have that info without lag? I need that every user of a organization in google to receive an email with the last logins info each time the user logs in.
I tryed with this sample: https://github.com/googleworkspace/apps-script-samples/blob/main/adminSDK/reports/quickstart.gs
function listLogins() {
const userKey = 'all';
const applicationName = 'login';
const optionalArgs = {
maxResults: 10
};
try {
const response = AdminReports.Activities.list(userKey, applicationName, optionalArgs);
const activities = response.items;
if (!activities || activities.length === 0) {
console.log('No logins found.');
return;
}
// Print login events
console.log('Logins:');
for (const activity of activities) {
console.log('%s: %s (%s)', activity.id.time, activity.actor.email,
activity.events[0].name);
}
} catch (err) {
// TODO (developer)- Handle exception from the Report API
console.log('Failed with error %s', err.message);
}
}
But get old data
Upvotes: 0
Views: 32