I want to use Google Classroom Java API in Tomcat Server as a REST API.
- I want the client-side code to generate an access token and refresh token and pass them to the REST API endpoints.
- The REST API then use the above token to call the following code to get the list of Courses:
objectOf(Classroom).courses().list().setPageSize(100).execute();
I am creating the Classroom as follows, where .getCredentials()
uses
GoogleAuthorizationCodeFlow.Builder
to create the credential required, but it opens a browser window to authorize the user and get the token. This doesn't work for me.
NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
Classroom classRoom = new Classroom.Builder(httpTransport, JSON_FACTORY, getCredentials(httpTransport))
.setApplicationName(APPLICATION_NAME).build();