Search code examples
google-classroom

Connect to google classroom from external website/app?


I need to somehow connect to google classroom from a students perspective, and list all assignments coming up soon. I can't find anything about this in the documentation, but using the google authentication I should be able to do it?


Solution

  • You can use the method courses.courseWork.list this will return a list of course work that the user is permitted to view.

    For the scope, as the document says:

    API requests also require the correct user scopes. Teachers can view assignments, create assignments, attach links to assignment submissions, and set submission grades. Students can view assignments, attach links to their assignment records, and turn-in and reclaim their submissions. Domain administrators can view coursework, but have no write permissions.

    Here's a sample code using appscript, you can just play around with it to familiarize yourself.

     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];
          Logger.log('%s (%s)', course.name, course.id);
        }
      } else {
        Logger.log('No courses found.');
      }
    }