Reputation: 11
I have been trying to use google classroom api and get student list as shown below.
I done everything as indicated in the google classroom api documentation (added all necessary scopes in google cloud platform - oAuth consent screen, enable api for google classroom and etc.), but still getting this error below:
Can anybody help me to solve this problem I've been stuck in for a week ?
Upvotes: 0
Views: 403
Reputation: 1057
Reviewing the part of the code I notice that the Service account is not impersonating any of the user of the Admin console.
If you have set up the domain wide delegation: A service account should have domain-wide access to be able to retrieve data on behalf of a user in your domain, otherwise it acts like just another account that is trying to access its own data from Classroom.
I would advise to review the guide https://developers.google.com/identity/protocols/oauth2/service-account#java
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.services.sqladmin.SQLAdminScopes;
// ...
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("MyProject-1234.json"))
.createScoped(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN));
delegated_credentials = credentials.with_subject('[email protected]')
Make sure that you are impersonating a Super Admin from your organization. The service account itself can't be an administrator on the domain, but it can impersonate a domain admin, without having to store the admin's credentials.
Upvotes: 0