I'm trying to use domain wide delegation on a service account to fetch some info from the admin sdk to generate reports. i got an already working codebase which i use with a gsuite domain. i wanted to use that same code to generate reports for another domain, so i set up a GCP project for this other domain. i created a service account, enabled domain wide delegation on it, and enabled the scopes for the service account. When i try to make any api call impersonating any account on the domain, i get the following error
adminService.activities().list(userKey='all', applicationName='meet').execute()
google.auth.exceptions.RefreshError: ('access_denied: Account restricted', '{\n "error": "access_denied",\n "error_description": "Account restricted",\n "error_uri":<url>}')
here's the code i use to create the service
credentials = service_account.Credentials.from_service_account_file(credentialsPath,
scopes=['https://www.googleapis.com/auth/admin.reports.audit.readonly',
"https://www.googleapis.com/auth/classroom.announcements.readonly",
"https://www.googleapis.com/auth/classroom.courses.readonly",
"https://www.googleapis.com/auth/classroom.coursework.students.readonly",
"https://www.googleapis.com/auth/classroom.profile.emails",
"https://www.googleapis.com/auth/classroom.rosters.readonly",
"https://www.googleapis.com/auth/classroom.student-submissions.students.readonly",
"https://www.googleapis.com/auth/classroom.topics.readonly"
])
delegated_credentials = credentials.with_subject(email)
return build('admin', 'reports_v1', credentials=delegated_credentials)
Again, this shouldn't be a programming problem since the same exact code is working for another domain, i think i'm missing something on the admin/GCP configuration side, but i can't figure out what, and i haven't found this exact error anywhere on the internet

Security > Advanced settings > Manage API client accessthen enter all your scopes for the client with your service account's client ID. - I hope this is helpful to youimpersonating any account on the domain, but only domain admins have the ability to access the reports API, so this can't be run as anyone but them. Also, have you made sure that you're not accidentally using the credentials for the service account on the other domain? - I hope this is helpful to youunauthorized_cilent, which makes sense. however i really can't understand whataccess_denied: Account restrictedcould mean - Fabio ProtoType22 De simone