Google Classroom API: get emails of course creators with Google App Script

Google Classroom API: get emails of course creators with Google App Script.
Anyone knows how to get emails of course creators with Google App Script?
I’m trying below piece of code & it is doing OK to get the list of names of the courses in Google Classroom. Now I’m trying to get emails of the course creators. thanks!

function listCourses() {
  var courses = [];
  var ownerId = [];
  var pageToken = null;
  var optionalArgs = {
    pageToken: pageToken,
    pageSize: 100
  };
  while (true) {
    var response = Classroom.Courses.list(optionalArgs);
    // @ts-ignore
    var courses = response.courses;
    if (!pageToken) {
       break;
    }
  }
  if (courses.length === 0) {
    Logger.log("No courses found.");
  } else {
    Logger.log("Courses:");
    // @ts-ignore
    for (course in courses) {
      // @ts-ignore
      Logger.log('%s (%s) (%s)', courses[course].name, courses[course].id, getEmail(courses[course].ownerId));
      //ownerId.push(listEmails(courses[course].ownerId));
      
      
    }
  }
  return ownerId;
  //return courses;
}

function getEmail(id) {
  //var emails = [];
  //var emails = Classroom.UserProfiles.get(id);  
  return Classroom.UserProfiles.get(id);
 //Logger.log('%s', emails.emailAddress);
}

92 thoughts on “Google Classroom API: get emails of course creators with Google App Script”

  1. Hello there, I found your blog by the use of Google while searching for a similar topic, your website got here up, it
    looks great. I have bookmarked it in my google bookmarks.

    Hello there, simply was aware of your blog via Google,
    and located that it is truly informative. I am going to
    watch out for brussels. I will appreciate if you happen to continue this in future.
    Numerous folks will likely be benefited out of your writing.
    Cheers! http://cleckleyfloors.com/

    Reply

Leave a Comment