I am building an app with Swift and Xcode. For it, I am using the Google Classroom API. When trying to turn in a homework assignment, I get this error : "@ProjectPermissionDenied The Developer Console project is not permitted to make this request."
Looking at other Stack Overflow posts, I saw that it was because the assignments were created by another Developer Console project and that I don't have access to turn them in. But, is there any way that I would be able to turn in the assignment?
This is the code in the App Delegate:
func turnInHomeworkAssignment(courseId: String, courseWorkId : String, studentSubmissionId : String, onCompleted : @escaping(Error?) -> ()) {
if self.service.authorizer != nil {
let turnInObject = GTLRClassroom_TurnInStudentSubmissionRequest.init()
let turnInAssignment = GTLRClassroomQuery_CoursesCourseWorkStudentSubmissionsTurnIn.query(withObject: turnInObject, courseId: courseId, courseWorkId: courseWorkId, identifier: studentSubmissionId)
self.service.executeQuery(turnInAssignment) { (ticket, results, error) in
onCompleted(error)
}
}
}
And when a button to turn in an an assignment is pressed then it will call this code:
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.turnInHomeworkAssignment(courseId: courseID, courseWorkId : courseWorkID, studentSubmissionId : studentSubmissionID) { (error) in
if error != nil {
print ("Error turning in Homework: \(String(describing: error?.localizedDescription))")
return
}
}
Thank you very much, Rosalie