-1

I try this code, but it returns a "Request had insufficient authentication scopes". I have more Classroom code in the same script that works properly.

  guardianInvitation = {
  'invitedEmailAddress': 'guardian@gmail.com',
}
  guardianInvitation= Classroom.UserProfiles.GuardianInvitations.create(guardianInvitation, 'student@mydomain.com') 
Enrique Umaran
  • 115
  • 1
  • 1
  • 9

2 Answers2

1

This question is from a few years ago, but I just tried the following and it works perfectly:

function guar (){ 
var gi = {invitedEmailAddress: 'user@gmail.com'};
Classroom.UserProfiles.GuardianInvitations.create(gi, 'user@school.edu.mx');  
}

But, before it will work you must go to Resources, then Advanced Google Services, and activate the Admin Directory API, then the Google Classroom API, and then the Groups Settings API, and then you must go to the part below where it says "These services must also be enabled in the Google Cloud Platform API Dashboard." and then you must activate these same three (Admin SDK, Groups Settings API, Google Classroom API). Then it should work just fine.

Jason Jurotich
  • 441
  • 4
  • 24
  • Keep in mind that if you are not an admin within the school, you may need to ask the SuperAdmin to activate these services. – Jason Jurotich Oct 21 '18 at 01:20
  • The administrator must also have activated the Guardian Access under the Google Classroom App in the Admin Console, or not even the Admin can run the GAS. – Jason Jurotich Nov 13 '18 at 00:09
  • The Groups Settings API is not required to send Guardian invitation. I'm not completely sure about the Admin SDK as my use case usually require both, Classroom and Admin SDK . – Rubén Mar 11 '19 at 23:12
0

There's a caution note inside Classroom service docs. The advanced service will only request 4 scopes—none of which support the Guardian features or methods.

The solution (quoted directly from those docs) is "don't use this advanced service and instead connect to the Classroom API directly using the same approach you would use to connect to an external API."

SSB
  • 430
  • 4
  • 8