2

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?

narcisrm
  • 25
  • 5

1 Answers1

0

The problem was that we were using an old version of the google library, and the root link of the API was deprecated.

I had to change

$this->rootUrl = 'https://prod-day0-classroom.sandbox.googleapis.com/';

to

$this->rootUrl = 'https://classroom.googleapis.com/';

Now it's working fine.

narcisrm
  • 25
  • 5