I want to create a push notification subscription, I delegated domain-level rights to Google Workspace, granted IAM rights to [email protected]
, but it didn’t work, here’s my code and error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://classroom.googleapis.com/v1/registrations?alt=json returned "The caller does not have permission". Details: "The caller does not have permission">
from googleapiclient.discovery import build
from google.oauth2.service_account import Credentials
SCOPES = ['https://www.googleapis.com/auth/classroom.push-notifications', 'https://www.googleapis.com/auth/classroom.rosters']
body = {
"feed": {
"feedType": "COURSE_WORK_CHANGES",
"courseWorkChangesInfo": {
"courseId": (courseId)
},
},
"cloudPubsubTopic": {
"topicName": "projects/(my-project)/topics/coursework-notifications"
}
}
def main():
service_account = 'secrets.json'
credentials = Credentials.from_service_account_file(
service_account, scopes=SCOPES)
delegate = credentials.with_subject("[email protected]")
service = build('classroom', 'v1', credentials=delegate)
try:
result = service.registrations().create(body=body).execute()
print(result)
except Exception as error:
print(error.content)
print(dir(error))
if __name__ == '__main__':
main()
P.S Email [email protected]
is Superadmin