Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 谷歌教室-使用应用程序脚本添加学生_Google Apps Script_Google Apps_Google Classroom_Google Apps For Education - Fatal编程技术网

Google apps script 谷歌教室-使用应用程序脚本添加学生

Google apps script 谷歌教室-使用应用程序脚本添加学生,google-apps-script,google-apps,google-classroom,google-apps-for-education,Google Apps Script,Google Apps,Google Classroom,Google Apps For Education,有一个域名和一个子域名分别是school.com和students.school.com 我使用谷歌应用程序脚本为每个班级创建了谷歌教室 现在问题来了, 我正在尝试将教师和学生加入谷歌教室。 我使用的超级管理员帐户是我的主域名(school.com) 因此,我可以将教师添加到教室中,但我不能将学生添加到教室中,因为它属于子域(students.school.com) 我的代码是这样的 function addTeachers() { Classroom.Courses.Teachers.cr

有一个域名和一个子域名分别是school.com和students.school.com

我使用谷歌应用程序脚本为每个班级创建了谷歌教室

现在问题来了,
我正在尝试将教师和学生加入谷歌教室。
我使用的超级管理员帐户是我的主域名(school.com)

因此,我可以将教师添加到教室中,但我不能将学生添加到教室中,因为它属于子域(students.school.com)

我的代码是这样的

function addTeachers() {
  Classroom.Courses.Teachers.create({
    userId: "teacher1@school.com",
  }, "123456789");
}

function addStudents() {
  Classroom.Courses.Students.create({
    userId: "student@students.school.com",
  }, "123456789");
}
当我运行
addStudents
函数时,会出现此错误,

Execution failed: The caller does not have permission

您需要确保这些域具有并允许来自其他域的用户添加到课程中。

对于Google教室,类/教师在一个域中,学生在另一个域中。在学生域中设置服务帐户。然后将域范围的权限委托给服务帐户,并提供所需的作用域,该作用域应为

auth/class.rosters

auth/教室.profile.email

auth/教室.profile.photos


并使用该服务帐户代表学生的google帐户(即使用courseid和enrollmentCode)执行courses.students.create方法。

谢谢您的回复。这两个域已将彼此列入白名单。它仍然不起作用。不作为评论发布,因为我意识到它不是GAS的一部分,但您可以使用API和服务帐户的外部工具,通过模拟学生并使用课程注册代码添加到课程中来完成所需的工作。看看是否有帮助。您可能无法在GAS中开立服务账户,但是。好的,2017年2月16日之后的某个时候,此功能停止工作。作为域管理员,我现在似乎根本无法创建和接受Google课堂邀请。现在我能做的最多的事情就是把自己作为一名教师加入教室,发出邀请,然后离开。我正在考虑使用一个服务帐户,该帐户已被授予我学校两个域的全域权限,并在冒充教师时发送邀请,在冒充学生时接受发送给学生的邀请。0否决票我对一个域中的教师和子域中的学生也有同样的问题。为了解决这个问题,我为课程中的每个学生创建了学生邀请,存储id,并通过id为每个学生接受邀请。我已使用gShell+0.10.3解决方案更正了我的答案