Update Google Account
Automatically Update Google Account Information for Employees
info
Purpose
This script is designed to:
- Retrieve employee data from EIM API.
- Compare data between today and yesterday.
- Update user information in Google Admin Directory if changes are detected: Employee Code, Job title, Department, Location
- Log processed accounts into a log file.
Operation Steps
-
Retrieve Employee Data
- Use the API Key and URL to call the API and fetch employee data.
- Save today's employee data into a JSON file.
-
Compare Data
- Load yesterday's employee data from a JSON file.
- Compare yesterday's and today's employee data to identify any changes.
-
Authentication and Authorization
- Use Google Service Account for authentication.
- Delegate authority to act on behalf of a specific user.
-
Update User Information
- Check and skip any accounts that have already been processed.
- Update details such as Employee Code, Job title, Department, Location.
- Log processed accounts into a log file.
-
Run Script and Generate Report
- The script updates information for all employees with detected changes.
- Generate and print a report after completion, listing the number of accounts updated, skipped, and any errors encountered.
-
Save Data and Manage Log File
- After completion, save today's data as yesterday's data for the next run.
- Rename the log file with the current date and time for better log management.