google-oauthgoogle-api-php-clientgoogle-classroom

How to find which Google Cloud Project is associated with an instance of Google Classroom?


I'm trying to pull our Google Classroom data into a custom web application via the Google API Client (PHP). I was able to make a successful call using a service account set up in Google Cloud, but the call returned no Classroom data.

I'm assuming the Classroom data must be associated with a different Google Cloud Project, I'm just not sure which one. I don't want to create a service account for every single project and test them, there are too many projects. I've looked everywhere and I can't seem to find the answer to the question: how do I find out WHICH project a Google Classroom integration is associated with, so I can configure the API Client accordingly?

I tried looking through all Classroom settings to see whether there was any information about the Google Cloud Project being used to store the data. I tried contacting Google Support, but so far I've had problems getting an answer to my question.

Ultimately I just want to pull the Classroom data into our web application.

Thanks


Solution

  • To use a service account with google classroom api you must configure Domain wide deligation. This will allow the service account to impersonate a user on your domain.

    $user_to_impersonate = "admin@yourdomain.com";
    $client->setSubject($user_to_impersonate);
    

    The service account will then behalf as though they were that person. It can then see everything that user has access to.

    Without delegation in place the service account doesn't have access to anything.