Fikirat Javadov
Fikirat Javadov

Reputation: 11

Google Classroom Api Error: Insufficient Permission

I have been trying to use google classroom api and get student list as shown below.

enter image description here

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:

enter image description here

Can anybody help me to solve this problem I've been stuck in for a week ?

Upvotes: 0

Views: 403

Answers (1)

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

  1. Create the credentials:

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));

  1. Delegate the authority and impersonate another user in your domain.

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

Related Questions