swift - Google Classroom API 和 Swift:交作业时出错
问题描述
我正在用 Swift 和 Xcode 构建一个应用程序。为此,我使用的是 Google Classroom API。尝试提交家庭作业时,我收到此错误:“@ProjectPermissionDenied 不允许开发者控制台项目提出此请求。”
查看其他 Stack Overflow 帖子,我发现这是因为作业是由另一个开发者控制台项目创建的,我无权将它们上交。但是,有什么方法可以让我上交任务?
这是 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)
}
}
}
当按下一个按钮来提交作业时,它将调用以下代码:
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
}
}
非常感谢你,罗莎莉
解决方案
推荐阅读
- python - 如何遍历只有 2 个小数点的列中的字符串,例如 100.00.0?
- javascript - JavaScript:获取嵌套对象(或 JSON)中给定键值对的路径
- python - 熊猫合并范围日期
- reactjs - 复选框返回
- javascript - 反应,对象没有渲染
- spring-boot - 为什么在 For 循环的每次迭代中都没有提交数据?
- android - Flutter - 后台通知服务
- python-3.x - 如何使用 pymongo 在 mongo db 的嵌套字典中更新整个列表?
- scala - 未能减少 Scala 中的匹配类型
- python - 使用 ibm_db 连接到 DB2,连接尝试开始但从未完成