I have a problem using Google Classroom API for accessing the list of classrooms. I get the following error:
Google_Service_Exception: { "error": { "code": 403, "message": "Google Classroom API (QA) has not been used in project XYZ before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/qa-classroom.sandbox.googleapis.com/overview?project=XYZ then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "errors": [ { "message": "Google Classroom API (QA) has not been used in project XYZ before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/qa-classroom.sandbox.googleapis.com/overview?project=XYZ then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "domain": "usageLimits", "reason": "accessNotConfigured", "extendedHelp": "https://console.developers.google.com" }
The problem is that it does not detect that the Classroom API is activated, because I'm pretty sure it is. If i go to the developer console and search for it, it shows up and it is activated, and it was activated more than 24h ago.
When I click on the link that the error shows me, it takes me to the developer console but the page is in blank, and if I open the Firefox console, I can see there is an error that says:
ERROR Error: ga Object: {"message":"Permission denied to get service [qa-classroom.sandbox.googleapis.com]\nHelp Token: MYTOKEN","permissionDenied":true,"errorExperience":2}`
I actually tried to delete the project and do it again with a new one, but I get the same result. I use other APIs as Group Settings, Calendar, Contacts... and all work well, but Classroom doesn't.
Basically this is the code I'm trying to use:
$connection = new Google_Client();
$connection->setClientId($clientId);
$connection->setSubject($delegatedAdmin);
$connection->useApplicationDefaultCredentials();
$connection->setIncludeGrantedScopes(true);
$connection->addScope(Google_Service_Classroom::CLASSROOM_COURSES);
$classroomService = new Google_Service_Classroom($connection);
$params = array(
'pageSize' => 10,
'pageToken' => NULL
);
$response = $classroomService->courses->listCourses($params);
The scopes are correctly configured in Security > API Controls. And I repeat, every other API call from Group Settings, Calendar or Contacts, works just fine.
Does anyone have any idea of what I'm doing wrong?