google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

Want to get the `Service Account` created datetime

Open LiNuo0 opened this issue 4 months ago • 0 comments

Determine this is the right repository

  • [x] I determined this is the correct repository in which to report this feature request.

Summary of the feature request

In my product, I want to retrieve the existing service accounts from my GCP project and get the creation datetime for each of them.

Here I want to check whether the service account was created too long time ago as I want to cleanup the orphan service account from the project

But I cannot get the creation datetime value.

Desired code experience

from googleapiclient import discovery

... ...
current_service_accouts = discovery.build("iam", "v1", credentials=my_credentials).projects().serviceAccounts().list(name="projects/xxx").execute()
for account in current_service_accouts:
    <if the service account was created 1 year ago>
         delete it

Expected results

I want to get the service account creation datetime value like service_account['createTimestamp'].

API client name and version

google-api-python-client 2.179.0

Use case

No response

Additional context

No response

LiNuo0 avatar Sep 01 '25 08:09 LiNuo0