如何修复 Google 课堂更新学生提交的草稿成绩和指定成绩的项目权限被拒绝问题
How to fixed Project Permission Denied problem for update draft grade and assigned grade of student submission from Google Classroom
我想使用 API 从 Google 课堂更新草稿成绩和指定成绩。当我使用 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);
然后当我 运行 本地主机上的上述代码时,我看到问题 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 密钥需要以下授权范围之一
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/classroom.coursework.students
https://www.googleapis.com/auth/classroom.coursework.me
根据课堂API documentation:
ProjectPermissionDenied
indicates that the request attempted to modify a resource associated with a different Developer Console project.
Possible Action: Indicate that your application cannot make the desired request. It can only be made by the Developer Console project of the OAuth client ID that created the resource.
因此,如果您尝试修改的资源是手动创建的,例如,这意味着它没有与任何开发人员项目相关联,因此您会收到错误消息。
您必须在同一个项目中创建这些资源才能成功执行此请求。
参考
我想使用 API 从 Google 课堂更新草稿成绩和指定成绩。当我使用 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);
然后当我 运行 本地主机上的上述代码时,我看到问题 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 密钥需要以下授权范围之一
Authorization Scopes Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/classroom.coursework.students https://www.googleapis.com/auth/classroom.coursework.me
根据课堂API documentation:
ProjectPermissionDenied
indicates that the request attempted to modify a resource associated with a different Developer Console project.Possible Action: Indicate that your application cannot make the desired request. It can only be made by the Developer Console project of the OAuth client ID that created the resource.
因此,如果您尝试修改的资源是手动创建的,例如,这意味着它没有与任何开发人员项目相关联,因此您会收到错误消息。
您必须在同一个项目中创建这些资源才能成功执行此请求。