3. Allow domain-wide delegation
-
In the Google Admin console, go to Security → Access and data control > API controls > Manage domain-wide delegation.
-
Click Add new and paste the client ID you copied in the last step.
-
Add these scopes (comma-separated):
https://www.googleapis.com/auth/classroom.courses,https://www.googleapis.com/auth/classroom.rosters,https://www.googleapis.com/auth/classroom.profile.emails,https://www.googleapis.com/auth/admin.directory.user.readonly
-
Click Authorize. The service account is then listed under API clients.

What each scope is for
| Scope | Used for |
|---|---|
classroom.courses | Listing, editing, archiving and deleting classrooms |
classroom.rosters | Counting, adding and removing teachers and students |
classroom.profile.emails | Teachers' and students' email addresses |
admin.directory.user.readonly | Looking up classroom owners' email addresses, searching for people, and showing their photos |