-1

I have created an assignment on the google classroom website which I would like to grade using the Google Classroom API. Based on the documentation this can be achieved with the following.

studentSubmission = {
  'assignedGrade': 99,
  'draftGrade': 80
}
service.courses().courseWork().studentSubmissions().patch(
    courseId=<course ID or alias>,
    courseWorkId=<courseWork ID>,
    id=<studentSubmission ID>,
    updateMask='assignedGrade,draftGrade',
    body=studentSubmission).execute()

The problem is I'm running to a permission error "@ProjectPermissionDenied The Developer Console project is not permitted to make this request." It is my understanding that this error occurs because the website is using a different Developer Console project than the one I am using the make API requests.

I am using the same Google account to authenticate the API and create coursework in Google Classroom. I have also confirmed I have all the required scopes and tested the API in the browser using the "Try this API" method and received the same permission error.

Since creating assignments through the website is necessary for my use case, I was wondering whether there was a way to get around the permission error so an assignment created on the website can be graded through the API?

Leon
  • 251
  • 2
  • 6

1 Answers1

0

According to this existing answer from a related post:

When modifying assignments/courseWork or student submissions, only the Developer console project that created those objects can modify them. This means that only projects that created the corresponding course work can modify them, otherwise a 403 PERMISSION_DENIED error is returned. You can easily determine if the course work item is associated with the Developer Console project making the request by checking the associatedWithDeveloper property on the Google Classroom course work response

SputnikDrunk2
  • 3,398
  • 1
  • 5
  • 17
  • I saw that as well, but I don't understand why the API uses a different developer console project than the UI. If I am unable to use the current developer console project would there then be a way for me to impersonate the one that is used by the website, or would I have to make a copy of the assignment with the API to assign grades? – Leon Oct 21 '21 at 23:17
  • I believe copying the the assignment with the API to assign grades would be the workaround that you can try. – SputnikDrunk2 Oct 22 '21 at 15:06