php - 如何修复从谷歌课堂更新草稿成绩和学生提交的指定成绩的项目权限被拒绝问题
问题描述
我想使用 API 从 Google Classroom 更新草稿成绩和指定成绩。当我使用Try this API测试更新草稿成绩和分配的成绩时,会出现以下问题。
问题:1
{
"error": {
"code": 403,
"message": "@ProjectPermissionDenied The Developer Console project is not permitted to make this request.",
"status": "PERMISSION_DENIED"
}
}
此错误可能是由于使用的凭据类型不足。尝试使用 OAuth 2.0。
本地主机代码:
$client = getClient();
$service = new Google_Service_Classroom($client);
$courseId = '393351980716';
$courseWorkId = '393445838699';
$id = 'Cg0Iu5q5vHkQ657M2bkL';
$post_body = new Google_Service_Classroom_StudentSubmission(array(
'assignedGrade' => 10,
'draftGrade' => 90
));
$params = array(
'updateMask' => 'assignedGrade,draftGrade'
);
$list = $service->courses_courseWork_studentSubmissions->patch($courseId, $courseWorkId, $id, $post_body,$params);
然后,当我在 localhost 上运行上述代码时,我看到了问题 2:
问题2
Fatal error: Uncaught Google\Service\Exception: {
"error": {
"code": 403,
"message": "@ProjectPermissionDenied The Developer Console project is not pe
rmitted to make this request.",
"errors": [
{
"message": "@ProjectPermissionDenied The Developer Console project is no
t permitted to make this request.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
如何解决这个问题呢?
解决方案
对于该 API 请求,您的 API 密钥需要以下授权范围之一
授权范围需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/classroom.coursework.students https://www.googleapis.com/auth/classroom.coursework.me
推荐阅读
- java - 具有数组类型记录的嵌套 Avro 记录反序列化
- mysql - 我需要优化表和查询
- c - 没有错误但分段(指针)错误
- excel - Excel:工作表事件根本不起作用
- php - 如何从 codeigniter 中的 URL 中删除方法名称?
- sql - SQL Server 中两个字符串之间的百分比匹配
- python - 为什么我的球体上的圆圈变成了 8 字形?
- linux - 在 bash 中使用多个核心
- java - 选择所有字段时缺少 Google Drive API v3 字段
- android - 使用 Gigya Android Sdk 实现“使用 Apple 登录”WebBridge