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