【问题标题】:Google Classroom - Add students using apps scriptGoogle Classroom - 使用应用脚本添加学生
【发布时间】:2017-05-11 08:57:28
【问题描述】:

有 1 个带有子域的域 - 分别为 school.com 和 students.school.com。

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

现在问题来了,
我正在尝试将教师和学生添加到 Google 课堂中。
我使用的“超级管理员”帐户在我的主域 (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

【问题讨论】:

  • 不作为评论发布,因为我意识到它不直接属于 GAS,但您可以使用带有 API 和服务帐户的外部工具,通过模拟学生并添加到使用课程注册代码的课程。看看this explanation 是否有帮助。您可能无法在 GAS 中进行服务帐户,但 this may help you go in the right direction.

标签: google-apps-script google-apps google-classroom google-apps-for-education


【解决方案1】:

对于 Google 课堂,班级/教师在一个域中,而学生在另一个域中。在学生域中设置服务帐户。然后将域范围的权限委托给服务帐户,并具有所需的范围,应该是

auth/classroom.rosters

auth/classroom.profile.emails

auth/classroom.profile.photos

并使用该服务帐户代表学生的 google 帐户执行 course.students.create 方法(也就是同时使用 courseid 和enrollmentCode。)

【讨论】:

  • 好的,在 2017 年 2 月 16 日之后的某个时间,这停止了工作。作为域管理员,我现在似乎根本无法创建和接受 Google 课堂邀请。现在我能做的最多的就是将自己添加为教室的老师,发送邀请,然后删除自己。我正在考虑使用一个服务帐户,该服务帐户已被委派给我学校的两个域,并在冒充教师时发送邀请,并在冒充学生时接受发送给学生的邀请。跨度>
  • 0 反对票 我对一个域中的教师和子域中的学生也有同样的问题。为了解决这个问题,我为课程中的每个学生创建了学生邀请,存储 ID,并按每个学生的 ID 接受邀请。
  • 我通过 gShell +0.10.3 使用的解决方案更正了我的答案
【解决方案2】:

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

【讨论】:

  • 感谢您的回复。两个域都已将对方列入白名单。还是不行。
猜你喜欢
  • 1970-01-01
  • 2019-09-24
  • 2020-08-31
  • 1970-01-01
  • 1970-01-01
  • 2019-05-14
  • 1970-01-01
  • 2022-12-10
  • 1970-01-01
相关资源
最近更新 更多