Skip to main content

Update Google Account

Automatically Update Google Account Information for Employees

Purpose

This script is designed to:

  1. Retrieve employee data from EIM API.
  2. Compare data between today and yesterday.
  3. Update user information in Google Admin Directory if changes are detected: Employee Code, Job title, Department, Location
  4. Log processed accounts into a log file.

Operation Steps

  1. 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.
  2. Compare Data

    • Load yesterday's employee data from a JSON file.
    • Compare yesterday's and today's employee data to identify any changes.
  3. Authentication and Authorization

    • Use Google Service Account for authentication.
    • Delegate authority to act on behalf of a specific user.
  4. 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.
  5. 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.
  6. 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.