Код: Выделить всё
googleapiclient.errors.HttpError:
Код: Выделить всё
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("no-reply@nemk.ukr.education")
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()
Подробнее здесь: https://stackoverflow.com/questions/790 ... ave-permis