I'm trying to write a PHP routine to import Google Classroom enrollment data into our database. Here are my scopes:
$client->setScopes([Google_Service_Classroom::CLASSROOM_COURSES_READONLY, Google_Service_Classroom::CLASSROOM_ROSTERS_READONLY, Google_Service_Classroom::CLASSROOM_PROFILE_EMAILS]);
Then I'm trying to run through the class enrollment data. (I made a class in my personal Google account, and got some co-workers to sign up for the class.) I'm getting profiles, but the emailAddress is always blank:
$results = $service->courses->listCourses();
foreach ($results->getCourses() as $course) {
$roster = $service->courses_students->listCoursesStudents($course->id);
foreach ($roster['students'] as $student) {
$profile = $student['profile'];
$name = $profile['name']; // Works
$first_name = $name['givenName']; // Works
$email = $profile['emailAddress']; // Always null
}
}
What am I missing?
This has mysteriously started to work...which does not make me feel great, but you know the feeling, right? There's no way to make the problem come back, so you just have to hope it doesn't...I will post here again if it does.
Maybe this is related to the fact that we just refilled the form with new scopes. So for the moment, I'm getting a warning that "Google hasn't verified the app" before it connects. So maybe it's the new scopes, or maybe it's the warning.