首页 > 解决方案 > 通过 Apps 脚本访问 Google Classroom 中的监护人信息

问题描述

我正在尝试使用课堂服务访问 Google Apps 脚本中的 Google Classroom Guardian 信息。我已经在 API 控制台中添加了服务并启用了 API。我可以访问一些数据(例如课程),但是当我尝试通过Classroom.UserProfiles.Guardians.list(student_id )if 失败并出现权限错误来获取监护人信息时。但是,如果我添加一个(虚拟)调用,Classroom.UserProfiles.GuardianInvitations.create()则会弹出具有所需范围的身份验证屏幕,然后脚本就可以工作了。是否有我遗漏的东西,或者这是Apps Scripts中的错误?

标签: google-apps-scriptgoogle-classroom

解决方案


尝试添加

https://www.googleapis.com/auth/classroom.guardianlinks.students

manifest.json文件中的范围,如下所示:

{
  ...
  "oauthScopes": [
    "https://www.googleapis.com/auth/classroom.guardianlinks.students`"
  ],
  ...
}

唯一的问题是您不会出现同意弹出窗口,并且您必须在manifest.json.

另一种解决方案是在注释中编写一个使用此范围的函数(对不起,但您需要搜索这个),因为您描述了您的问题,它看起来像一个错误。但是我给你的解决方案应该有效。

参考

Classroom.UserProfiles.Guardians.list 范围

授权范围

有用的阅读链接


推荐阅读