Created
March 21, 2022 18:01
-
-
Save GaetanoPiazzolla/ab5c540bb8d60642e171d969807b9391 to your computer and use it in GitHub Desktop.
Boilerplate code to start working with the Form and the Drive APIs from Google
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | |
import com.google.api.client.json.JsonFactory; | |
import com.google.api.client.json.jackson2.JacksonFactory; | |
import com.google.api.services.drive.Drive; | |
import com.google.api.services.forms.v1.Forms; | |
import java.io.IOException; | |
import java.security.GeneralSecurityException; | |
public class Boilerplate { | |
private static final String APPLICATION_NAME = "google-form-api-project"; | |
private static Drive driveService; | |
private static Forms formsService; | |
static { | |
try { | |
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); | |
driveService = new Drive.Builder(GoogleNetHttpTransport.newTrustedTransport(), | |
jsonFactory, null) | |
.setApplicationName(APPLICATION_NAME).build(); | |
formsService = new Forms.Builder(GoogleNetHttpTransport.newTrustedTransport(), | |
jsonFactory, null) | |
.setApplicationName(APPLICATION_NAME).build(); | |
} catch (GeneralSecurityException | IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment