Я добрался до этого, и это отлично работает:
Код: Выделить всё
from googleapiclient import discovery
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_info(
service_account_info,
scopes=("https://www.googleapis.com/auth/admin.directory.user.readonly", ),
)
service = discovery.build(
'admin',
'directory_v1',
credentials=credentials.with_subject('my_admin@domain.com'),
)
users = service.users().list(customer='my_customer').execute()
Код: Выделить всё
service = discovery.build('admin', 'directory_v1', credentials=credentials) #
Подробнее здесь: [url]https://stackoverflow.com/questions/78722310/how-to-list-gdrive-users-through-a-service-account[/url]