I've been testing the Google Classroom Api and can't seem to get the courseWorkList method to run getting a caller error
I've basically cut and pasted code from the reference and it works if i remove the classCourseWork line. Otherwise I get a "The caller does not have permission" error. I've enabled the API services, approved it to run, etc. Any help in getting this one sorted?
function listCourses() {
var optionalArgs = {
pageSize: 10
};
var response = Classroom.Courses.list(optionalArgs);
var courses = response.courses;
if (courses && courses.length > 0) {
for (i = 0; i < courses.length; i++) {
var course = courses[i];
var classCourseWork = Classroom.Courses.CourseWork.list(course.id);
}
Logger.log('%s (%s)', course.name, course.id);
} else {
Logger.log('No courses found.');
}
}
I've tried your code, here are the scenarios:
As a student:
Your code is working fine.
I've also received "The caller does not have permission" error.
You might want to check this open issue tracker, that a teacher cannot access the coursework (or the students' turned-in assignments) in their course, getting the same permission error. It was updated and was filed a ticket internally, we can follow this ticket to be updated.
Hope this helps.