diff --git a/adminSDK/alertcenter/quickstart/src/main/java/AdminSDKAlertCenterQuickstart.java b/adminSDK/alertcenter/quickstart/src/main/java/AdminSDKAlertCenterQuickstart.java index ded0d8fe..4b582727 100644 --- a/adminSDK/alertcenter/quickstart/src/main/java/AdminSDKAlertCenterQuickstart.java +++ b/adminSDK/alertcenter/quickstart/src/main/java/AdminSDKAlertCenterQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/adminSDK/directory/quickstart/src/main/java/AdminSDKDirectoryQuickstart.java b/adminSDK/directory/quickstart/src/main/java/AdminSDKDirectoryQuickstart.java index a93605db..114d29e8 100644 --- a/adminSDK/directory/quickstart/src/main/java/AdminSDKDirectoryQuickstart.java +++ b/adminSDK/directory/quickstart/src/main/java/AdminSDKDirectoryQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/adminSDK/reports/quickstart/src/main/java/AdminSDKReportsQuickstart.java b/adminSDK/reports/quickstart/src/main/java/AdminSDKReportsQuickstart.java index 2a63f0aa..e1c1550b 100644 --- a/adminSDK/reports/quickstart/src/main/java/AdminSDKReportsQuickstart.java +++ b/adminSDK/reports/quickstart/src/main/java/AdminSDKReportsQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/adminSDK/reseller/quickstart/src/main/java/AdminSDKResellerQuickstart.java b/adminSDK/reseller/quickstart/src/main/java/AdminSDKResellerQuickstart.java index d0f45ff4..3a6b298d 100644 --- a/adminSDK/reseller/quickstart/src/main/java/AdminSDKResellerQuickstart.java +++ b/adminSDK/reseller/quickstart/src/main/java/AdminSDKResellerQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appsScript/quickstart/src/main/java/AppsScriptQuickstart.java b/appsScript/quickstart/src/main/java/AppsScriptQuickstart.java index 221e98bc..d0355e6b 100644 --- a/appsScript/quickstart/src/main/java/AppsScriptQuickstart.java +++ b/appsScript/quickstart/src/main/java/AppsScriptQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/calendar/quickstart/src/main/java/CalendarQuickstart.java b/calendar/quickstart/src/main/java/CalendarQuickstart.java index 0ae61d8f..52c8f491 100644 --- a/calendar/quickstart/src/main/java/CalendarQuickstart.java +++ b/calendar/quickstart/src/main/java/CalendarQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,7 +44,6 @@ public class CalendarQuickstart { /** Global instance of the JSON factory. */ private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance(); /** Directory to store authorization tokens for this application. */ - private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance(); private static final String TOKENS_DIRECTORY_PATH = "tokens"; /** diff --git a/calendar/sync/pom.xml b/calendar/sync/pom.xml index 29f97014..486fca90 100644 --- a/calendar/sync/pom.xml +++ b/calendar/sync/pom.xml @@ -85,4 +85,4 @@ 1.32.1 UTF-8 - + \ No newline at end of file diff --git a/classroom/quickstart/src/main/java/ClassroomQuickstart.java b/classroom/quickstart/src/main/java/ClassroomQuickstart.java index 29d9ae24..3357c0e9 100644 --- a/classroom/quickstart/src/main/java/ClassroomQuickstart.java +++ b/classroom/quickstart/src/main/java/ClassroomQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/docs/outputJSON/src/main/java/OutputJSON.java b/docs/outputJSON/src/main/java/OutputJSON.java index 84e41f4e..8826e7a0 100644 --- a/docs/outputJSON/src/main/java/OutputJSON.java +++ b/docs/outputJSON/src/main/java/OutputJSON.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/docs/quickstart/src/main/java/DocsQuickstart.java b/docs/quickstart/src/main/java/DocsQuickstart.java index f8321a67..ea0c303e 100644 --- a/docs/quickstart/src/main/java/DocsQuickstart.java +++ b/docs/quickstart/src/main/java/DocsQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/drive/activity-v2/quickstart/build.gradle b/drive/activity-v2/quickstart/build.gradle index 0ae0460b..ec19591d 100644 --- a/drive/activity-v2/quickstart/build.gradle +++ b/drive/activity-v2/quickstart/build.gradle @@ -11,7 +11,8 @@ repositories { } dependencies { - implementation 'com.google.api-client:google-api-client:1.32.2' + +implementation 'com.google.api-client:google-api-client:1.32.2' implementation 'com.google.oauth-client:google-oauth-client-jetty:1.32.1' implementation 'com.google.apis:google-api-services-driveactivity:v2-rev20210319-1.32.1' } diff --git a/drive/activity-v2/quickstart/src/main/java/DriveActivityQuickstart.java b/drive/activity-v2/quickstart/src/main/java/DriveActivityQuickstart.java index db0b7c36..4ddc9856 100644 --- a/drive/activity-v2/quickstart/src/main/java/DriveActivityQuickstart.java +++ b/drive/activity-v2/quickstart/src/main/java/DriveActivityQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/drive/activity/quickstart/src/main/java/DriveActivityQuickstart.java b/drive/activity/quickstart/src/main/java/DriveActivityQuickstart.java index c28cdd13..0af2839e 100644 --- a/drive/activity/quickstart/src/main/java/DriveActivityQuickstart.java +++ b/drive/activity/quickstart/src/main/java/DriveActivityQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,8 +48,7 @@ public class DriveActivityQuickstart { private static FileDataStoreFactory DATA_STORE_FACTORY; /** Global instance of the JSON factory. */ - private static final JsonFactory JSON_FACTORY = - GsonFactory.getDefaultInstance(); + private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance(); /** Global instance of the HTTP transport. */ private static HttpTransport HTTP_TRANSPORT; diff --git a/drive/quickstart/build.gradle b/drive/quickstart/build.gradle index 5a86fe3c..41d3b574 100644 --- a/drive/quickstart/build.gradle +++ b/drive/quickstart/build.gradle @@ -5,7 +5,6 @@ mainClassName = 'DriveQuickstart' sourceCompatibility = 11 targetCompatibility = 11 version = '1.0' - repositories { mavenCentral() } diff --git a/drive/quickstart/src/main/java/DriveQuickstart.java b/drive/quickstart/src/main/java/DriveQuickstart.java index b9df6ab6..dbe339b1 100644 --- a/drive/quickstart/src/main/java/DriveQuickstart.java +++ b/drive/quickstart/src/main/java/DriveQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/gmail/quickstart/src/main/java/GmailQuickstart.java b/gmail/quickstart/src/main/java/GmailQuickstart.java index f6d1e569..c1a5b58f 100644 --- a/gmail/quickstart/src/main/java/GmailQuickstart.java +++ b/gmail/quickstart/src/main/java/GmailQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/people/quickstart/build.gradle b/people/quickstart/build.gradle index ef620f9a..d3baf485 100644 --- a/people/quickstart/build.gradle +++ b/people/quickstart/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'application' mainClassName = 'PeopleQuickstart' sourceCompatibility = 11 targetCompatibility = 11 - version = '1.0' repositories { diff --git a/people/quickstart/src/main/java/PeopleQuickstart.java b/people/quickstart/src/main/java/PeopleQuickstart.java index a0301f2d..4678f347 100644 --- a/people/quickstart/src/main/java/PeopleQuickstart.java +++ b/people/quickstart/src/main/java/PeopleQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sheets/quickstart/src/main/java/SheetsQuickstart.java b/sheets/quickstart/src/main/java/SheetsQuickstart.java index e7d04d4c..32d57857 100644 --- a/sheets/quickstart/src/main/java/SheetsQuickstart.java +++ b/sheets/quickstart/src/main/java/SheetsQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sheets/snippets/src/test/java/BaseTest.java b/sheets/snippets/src/test/java/BaseTest.java index 34ff8dad..ae4e32a8 100644 --- a/sheets/snippets/src/test/java/BaseTest.java +++ b/sheets/snippets/src/test/java/BaseTest.java @@ -1,7 +1,8 @@ -import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.auth.http.HttpCredentialsAdapter; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpTransport; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.services.drive.Drive; import com.google.api.services.drive.DriveScopes; import com.google.api.services.sheets.v4.Sheets; @@ -59,34 +60,34 @@ public void publish(LogRecord record) { }); } - public GoogleCredential getCredential() throws IOException { - return GoogleCredential.getApplicationDefault() - .createScoped(Arrays.asList(DriveScopes.DRIVE)); + public GoogleCredentials getCredential() throws IOException { + return GoogleCredentials.getApplicationDefault() + .createScoped(Arrays.asList(DriveScopes.DRIVE)); } - public Sheets buildService(GoogleCredential credential) throws IOException, - GeneralSecurityException { + public Sheets buildService(GoogleCredentials credential) throws IOException, + GeneralSecurityException { return new Sheets.Builder( - GoogleNetHttpTransport.newTrustedTransport(), - JacksonFactory.getDefaultInstance(), - credential) - .setApplicationName("Sheets API Snippets") - .build(); + GoogleNetHttpTransport.newTrustedTransport(), + GsonFactory.getDefaultInstance(), + new HttpCredentialsAdapter(credential)) + .setApplicationName("Sheets API Snippets") + .build(); } - public Drive buildDriveService(GoogleCredential credential) - throws IOException, GeneralSecurityException { + public Drive buildDriveService(GoogleCredentials credential) + throws IOException, GeneralSecurityException { return new Drive.Builder( - GoogleNetHttpTransport.newTrustedTransport(), - JacksonFactory.getDefaultInstance(), - credential) - .setApplicationName("Sheets API Snippets") - .build(); + GoogleNetHttpTransport.newTrustedTransport(), + GsonFactory.getDefaultInstance(), + new HttpCredentialsAdapter(credential)) + .setApplicationName("Sheets API Snippets") + .build(); } @Before public void setup() throws IOException, GeneralSecurityException { - GoogleCredential credential = getCredential(); + GoogleCredentials credential = getCredential(); this.service = buildService(credential); this.driveService = buildDriveService(credential); this.filesToDelete.clear(); @@ -109,47 +110,47 @@ protected void deleteFileOnCleanup(String id) { protected String createTestSpreadsheet() throws IOException { Spreadsheet spreadsheet = new Spreadsheet() - .setProperties(new SpreadsheetProperties() - .setTitle("Test Spreadsheet")); + .setProperties(new SpreadsheetProperties() + .setTitle("Test Spreadsheet")); spreadsheet = service.spreadsheets().create(spreadsheet) - .setFields("spreadsheetId") - .execute(); + .setFields("spreadsheetId") + .execute(); return spreadsheet.getSpreadsheetId(); } protected void populateValuesWithStrings(String spreadsheetId) throws IOException { List requests = new ArrayList<>(); requests.add(new Request().setRepeatCell(new RepeatCellRequest() - .setRange(new GridRange() - .setSheetId(0) - .setStartRowIndex(0) - .setEndRowIndex(10) - .setStartColumnIndex(0) - .setEndColumnIndex(10)) - .setCell(new CellData() - .setUserEnteredValue(new ExtendedValue() - .setStringValue("Hello"))) - .setFields("userEnteredValue"))); + .setRange(new GridRange() + .setSheetId(0) + .setStartRowIndex(0) + .setEndRowIndex(10) + .setStartColumnIndex(0) + .setEndColumnIndex(10)) + .setCell(new CellData() + .setUserEnteredValue(new ExtendedValue() + .setStringValue("Hello"))) + .setFields("userEnteredValue"))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest() - .setRequests(requests); + .setRequests(requests); service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); } protected void populateValuesWithNumbers(String spreadsheetId) throws IOException { List requests = new ArrayList<>(); requests.add(new Request().setRepeatCell(new RepeatCellRequest() - .setRange(new GridRange() - .setSheetId(0) - .setStartRowIndex(0) - .setEndRowIndex(10) - .setStartColumnIndex(0) - .setEndColumnIndex(10)) - .setCell(new CellData() - .setUserEnteredValue(new ExtendedValue() - .setNumberValue(1337D))) - .setFields("userEnteredValue"))); + .setRange(new GridRange() + .setSheetId(0) + .setStartRowIndex(0) + .setEndRowIndex(10) + .setStartColumnIndex(0) + .setEndColumnIndex(10)) + .setCell(new CellData() + .setUserEnteredValue(new ExtendedValue() + .setNumberValue(1337D))) + .setFields("userEnteredValue"))); BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest() - .setRequests(requests); + .setRequests(requests); service.spreadsheets().batchUpdate(spreadsheetId, body).execute(); } } diff --git a/slides/quickstart/src/main/java/SlidesQuickstart.java b/slides/quickstart/src/main/java/SlidesQuickstart.java index dc776391..cb512aaf 100644 --- a/slides/quickstart/src/main/java/SlidesQuickstart.java +++ b/slides/quickstart/src/main/java/SlidesQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/slides/snippets/src/main/java/Snippets.java b/slides/snippets/src/main/java/Snippets.java index c1c07907..a04836c4 100644 --- a/slides/snippets/src/main/java/Snippets.java +++ b/slides/snippets/src/main/java/Snippets.java @@ -1,4 +1,4 @@ -import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.auth.oauth2.GoogleCredentials; import com.google.api.services.drive.Drive; import com.google.api.services.drive.model.File; import com.google.api.services.sheets.v4.Sheets; @@ -119,7 +119,7 @@ public BatchUpdatePresentationResponse createTextBoxWithText( public BatchUpdatePresentationResponse createImage(String presentationId, String slideId, - GoogleCredential credential) + GoogleCredentials credential) throws IOException { Slides slidesService = this.service; // [START slides_create_image] diff --git a/slides/snippets/src/test/java/BaseTest.java b/slides/snippets/src/test/java/BaseTest.java index 99e97610..77aa0f7f 100644 --- a/slides/snippets/src/test/java/BaseTest.java +++ b/slides/snippets/src/test/java/BaseTest.java @@ -1,7 +1,8 @@ -import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.auth.http.HttpCredentialsAdapter; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpTransport; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.services.drive.Drive; import com.google.api.services.drive.DriveScopes; import com.google.api.services.sheets.v4.Sheets; @@ -25,7 +26,7 @@ public class BaseTest { enableLogging(); } - protected GoogleCredential credential; + protected GoogleCredentials credential; protected Slides service; protected Drive driveService; protected Sheets sheetsService; @@ -55,37 +56,37 @@ public void publish(LogRecord record) { }); } - public GoogleCredential getCredential() throws IOException { - return GoogleCredential.getApplicationDefault() + public GoogleCredentials getCredential() throws IOException { + return GoogleCredentials.getApplicationDefault() .createScoped(Arrays.asList(DriveScopes.DRIVE)); } - public Slides buildService(GoogleCredential credential) + public Slides buildService(GoogleCredentials credential) throws IOException, GeneralSecurityException { return new Slides.Builder( GoogleNetHttpTransport.newTrustedTransport(), - JacksonFactory.getDefaultInstance(), - credential) + GsonFactory.getDefaultInstance(), + new HttpCredentialsAdapter(credential)) .setApplicationName("Slides API Snippets") .build(); } - public Drive buildDriveService(GoogleCredential credential) + public Drive buildDriveService(GoogleCredentials credential) throws IOException, GeneralSecurityException { return new Drive.Builder( GoogleNetHttpTransport.newTrustedTransport(), - JacksonFactory.getDefaultInstance(), - credential) + GsonFactory.getDefaultInstance(), + new HttpCredentialsAdapter(credential)) .setApplicationName("Slides API Snippets") .build(); } - public Sheets buildSheetsService(GoogleCredential credential) + public Sheets buildSheetsService(GoogleCredentials credential) throws IOException, GeneralSecurityException { return new Sheets.Builder( GoogleNetHttpTransport.newTrustedTransport(), - JacksonFactory.getDefaultInstance(), - credential) + GsonFactory.getDefaultInstance(), + new HttpCredentialsAdapter(credential)) .setApplicationName("Slides API Snippets") .build(); } diff --git a/tasks/quickstart/src/main/java/TasksQuickstart.java b/tasks/quickstart/src/main/java/TasksQuickstart.java index 3b8abca9..df965fb5 100644 --- a/tasks/quickstart/src/main/java/TasksQuickstart.java +++ b/tasks/quickstart/src/main/java/TasksQuickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.util.store.FileDataStoreFactory; import com.google.api.services.tasks.Tasks; import com.google.api.services.tasks.TasksScopes; @@ -38,7 +38,7 @@ public class TasksQuickstart { private static final String APPLICATION_NAME = "Google Tasks API Java Quickstart"; - private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance(); private static final String TOKENS_DIRECTORY_PATH = "tokens"; /** @@ -81,7 +81,7 @@ public static void main(String... args) throws IOException, GeneralSecurityExcep // Print the first 10 task lists. TaskLists result = service.tasklists().list() - .setMaxResults(10L) + .setMaxResults(10) .execute(); List taskLists = result.getItems(); if (taskLists == null || taskLists.isEmpty()) { diff --git a/vault/quickstart/src/main/java/Quickstart.java b/vault/quickstart/src/main/java/Quickstart.java index 36b2a8c2..f68aa56c 100644 --- a/vault/quickstart/src/main/java/Quickstart.java +++ b/vault/quickstart/src/main/java/Quickstart.java @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpTransport; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.json.JsonFactory; import com.google.api.client.util.store.FileDataStoreFactory; import com.google.api.services.vault.v1.VaultScopes; @@ -41,13 +41,14 @@ public class Quickstart { /** Directory to store authorization tokens for this application. */ private static final java.io.File DATA_STORE_DIR = new java.io.File("tokens"); + private static final String CREDENTIALS_FILE_PATH = "/credentials.json"; /** Global instance of the {@link FileDataStoreFactory}. */ private static FileDataStoreFactory DATA_STORE_FACTORY; /** Global instance of the JSON factory. */ private static final JsonFactory JSON_FACTORY = - JacksonFactory.getDefaultInstance(); + GsonFactory.getDefaultInstance(); /** Global instance of the HTTP transport. */ private static HttpTransport HTTP_TRANSPORT;