I am using the Classroom Share Button to let users create assignments with resources from my Website on Google Classroom.
Is it possible to retrieve the courseId and the courseWorkId of the newly created assignment? I need this info to be able to store it on my website and reuse it later.
I already tried to use the callback "onsharecomplete", but it does not seem to get the required info as parameter. I also could not find any documentation about the arguments of this method.
My HTML looks like this:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div id="google-classroom-div">
<div className="g-sharetoclassroom" data-size="32" data-url="https://www.example.com" data-onsharecomplete="onShareComplete"></div>
</div>
And the javascript to render the button and handle the callback looks like this:
gapi.sharetoclassroom.go("google-classroom-div");
window.onShareComplete = (arg1, arg2) => {
console.log(arg1); // is undefined
console.log(arg2); // contains some weird data
};
I know that there is another way to create assignments by using the Classroom API, i.e. the REST Resource v1.courses.courseWork.create but then I would have to create the UI for choosing the course and posting the assignment on my own which I would like to avoid.