Skip to content

Commit 86e43a3

Browse files
committed
Merge branch 'master' of github.com:gsuitedevs/java-samples
2 parents b2a1498 + ab0795e commit 86e43a3

19 files changed

Lines changed: 79 additions & 84 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ gradlew.bat
3030
*.properties
3131

3232
client_secret.json
33+
credentials.json
34+
tokens/
3335

3436
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
3537
hs_err_pid*
@@ -38,4 +40,4 @@ hs_err_pid*
3840
.settings/
3941
.classpath
4042
.project
41-
properties
43+
properties

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ jdk:
55
# Use a Build Matrix for subdirs (https://lord.io/blog/2014/travis-multiple-subdirs/)
66
env:
77
- DIR=adminSDK/directory/quickstart
8-
- DIR=adminSDK/groupsMigration/quickstart
9-
- DIR=adminSDK/groupsSettings/quickstart
10-
- DIR=adminSDK/licensing/quickstart
118
- DIR=adminSDK/reports/quickstart
129
- DIR=adminSDK/reseller/quickstart
1310
- DIR=appsScript/quickstart

adminSDK/directory/quickstart/src/main/java/AdminSDKDirectoryQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@
3838
public class AdminSDKDirectoryQuickstart {
3939
private static final String APPLICATION_NAME = "Google Admin SDK Directory API Java Quickstart";
4040
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
41-
private static final String CREDENTIALS_FOLDER = "credentials"; // Directory to store user credentials.
41+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4242

4343
/**
4444
* Global instance of the scopes required by this quickstart.
4545
* If modifying these scopes, delete your previously saved credentials folder at /secret.
4646
*/
4747
private static final List<String> SCOPES = Collections.singletonList(DirectoryScopes.ADMIN_DIRECTORY_USER_READONLY);
48-
private static final String CLIENT_SECRET_DIR = "client_secret.json";
48+
private static final String CREDENTIALS_FILE_PATH = "credentials.json";
4949

5050
/**
5151
* Creates an authorized Credential object.
5252
* @param HTTP_TRANSPORT The network HTTP Transport.
5353
* @return An authorized Credential object.
54-
* @throws IOException If there is no client_secret.
54+
* @throws IOException If the credentials.json file cannot be found.
5555
*/
5656
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
5757
// Load client secrets.
58-
InputStream in = AdminSDKDirectoryQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
58+
InputStream in = AdminSDKDirectoryQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
5959
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
6060

6161
// Build flow and trigger user authorization request.
6262
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
6363
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
64-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(CREDENTIALS_FOLDER)))
64+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
6565
.setAccessType("offline")
6666
.build();
6767
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

adminSDK/reports/quickstart/src/main/java/AdminSDKReportsQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@
3838
public class AdminSDKReportsQuickstart {
3939
private static final String APPLICATION_NAME = "Google Admin SDK Reports API Java Quickstart";
4040
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
41-
private static final String CREDENTIALS_FOLDER = "credentials"; // Directory to store user credentials.
41+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4242

4343
/**
4444
* Global instance of the scopes required by this quickstart.
4545
* If modifying these scopes, delete your previously saved credentials folder at /secret.
4646
*/
4747
private static final List<String> SCOPES = Collections.singletonList(ReportsScopes.ADMIN_REPORTS_AUDIT_READONLY);
48-
private static final String CLIENT_SECRET_DIR = "client_secret.json";
48+
private static final String CREDENTIALS_FILE_PATH = "credentials.json";
4949

5050
/**
5151
* Creates an authorized Credential object.
5252
* @param HTTP_TRANSPORT The network HTTP Transport.
5353
* @return An authorized Credential object.
54-
* @throws IOException If there is no client_secret.
54+
* @throws IOException If the credentials.json file cannot be found.
5555
*/
5656
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
5757
// Load client secrets.
58-
InputStream in = AdminSDKReportsQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
58+
InputStream in = AdminSDKReportsQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
5959
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
6060

6161
// Build flow and trigger user authorization request.
6262
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
6363
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
64-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(CREDENTIALS_FOLDER)))
64+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
6565
.setAccessType("offline")
6666
.build();
6767
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

adminSDK/reseller/quickstart/src/main/java/AdminSDKResellerQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@
3838
public class AdminSDKResellerQuickstart {
3939
private static final String APPLICATION_NAME = "Google Admin SDK Reseller API Java Quickstart";
4040
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
41-
private static final String CREDENTIALS_FOLDER = "credentials"; // Directory to store user credentials.
41+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4242

4343
/**
4444
* Global instance of the scopes required by this quickstart.
4545
* If modifying these scopes, delete your previously saved credentials folder at /secret.
4646
*/
4747
private static final List<String> SCOPES = Collections.singletonList(ResellerScopes.APPS_ORDER);
48-
private static final String CLIENT_SECRET_DIR = "client_secret.json";
48+
private static final String CREDENTIALS_FILE_PATH = "credentials.json";
4949

5050
/**
5151
* Creates an authorized Credential object.
5252
* @param HTTP_TRANSPORT The network HTTP Transport.
5353
* @return An authorized Credential object.
54-
* @throws IOException If there is no client_secret.
54+
* @throws IOException If the credentials.json file cannot be found.
5555
*/
5656
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
5757
// Load client secrets.
58-
InputStream in = AdminSDKResellerQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
58+
InputStream in = AdminSDKResellerQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
5959
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
6060

6161
// Build flow and trigger user authorization request.
6262
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
6363
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
64-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(CREDENTIALS_FOLDER)))
64+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
6565
.setAccessType("offline")
6666
.build();
6767
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

appsScript/execute/src/main/java/Execute.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
public class Execute {
18-
// [START apps_script_execute]
18+
// [START apps_script_api_execute]
1919
/**
2020
* Create a HttpRequestInitializer from the given one, except set
2121
* the HTTP read timeout to be longer than the default (to allow
@@ -137,5 +137,5 @@ public static void main(String[] args) throws IOException {
137137
e.printStackTrace(System.out);
138138
}
139139
}
140-
// [END apps_script_execute]
140+
// [END apps_script_api_execute]
141141
}

appsScript/quickstart/src/main/java/AppsScriptQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,30 @@
4040
public class AppsScriptQuickstart {
4141
private static final String APPLICATION_NAME = "Apps Script API Java Quickstart";
4242
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
43-
private static final String CREDENTIALS_FOLDER = "credentials"; // Directory to store user credentials.
43+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4444

4545
/**
4646
* Global instance of the scopes required by this quickstart.
4747
* If modifying these scopes, delete your previously saved credentials folder at /secret.
4848
*/
4949
private static final List<String> SCOPES = Collections.singletonList("https://www.googleapis.com/auth/script.projects");
50-
private static final String CLIENT_SECRET_DIR = "client_secret.json";
50+
private static final String CREDENTIALS_FILE_PATH = "credentials.json";
5151

5252
/**
5353
* Creates an authorized Credential object.
5454
* @param HTTP_TRANSPORT The network HTTP Transport.
5555
* @return An authorized Credential object.
56-
* @throws IOException If there is no client_secret.
56+
* @throws IOException If the credentials.json file cannot be found.
5757
*/
5858
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
5959
// Load client secrets.
60-
InputStream in = AppsScriptQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
60+
InputStream in = AppsScriptQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
6161
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
6262

6363
// Build flow and trigger user authorization request.
6464
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
6565
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
66-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(CREDENTIALS_FOLDER)))
66+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
6767
.setAccessType("offline")
6868
.build();
6969
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

calendar/quickstart/src/main/java/CalendarQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,30 @@
3939
public class CalendarQuickstart {
4040
private static final String APPLICATION_NAME = "Google Calendar API Java Quickstart";
4141
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
42-
private static final String CREDENTIALS_FOLDER = "credentials"; // Directory to store user credentials.
42+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4343

4444
/**
4545
* Global instance of the scopes required by this quickstart.
4646
* If modifying these scopes, delete your previously saved credentials/ folder.
4747
*/
4848
private static final List<String> SCOPES = Collections.singletonList(CalendarScopes.CALENDAR_READONLY);
49-
private static final String CLIENT_SECRET_DIR = "client_secret.json";
49+
private static final String CREDENTIALS_FILE_PATH = "credentials.json";
5050

5151
/**
5252
* Creates an authorized Credential object.
5353
* @param HTTP_TRANSPORT The network HTTP Transport.
5454
* @return An authorized Credential object.
55-
* @throws IOException If there is no client_secret.
55+
* @throws IOException If the credentials.json file cannot be found.
5656
*/
5757
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
5858
// Load client secrets.
59-
InputStream in = CalendarQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
59+
InputStream in = CalendarQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
6060
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
6161

6262
// Build flow and trigger user authorization request.
6363
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
6464
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
65-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(CREDENTIALS_FOLDER)))
65+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
6666
.setAccessType("offline")
6767
.build();
6868
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

classroom/quickstart/src/main/java/ClassroomQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,30 @@
3737
public class ClassroomQuickstart {
3838
private static final String APPLICATION_NAME = "Google Classroom API Java Quickstart";
3939
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
40-
private static final String CREDENTIALS_FOLDER = "credentials"; // Directory to store user credentials.
40+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4141

4242
/**
4343
* Global instance of the scopes required by this quickstart.
4444
* If modifying these scopes, delete your previously saved credentials/ folder.
4545
*/
4646
private static final List<String> SCOPES = Collections.singletonList(ClassroomScopes.CLASSROOM_COURSES_READONLY);
47-
private static final String CLIENT_SECRET_DIR = "client_secret.json";
47+
private static final String CREDENTIALS_FILE_PATH = "credentials.json";
4848

4949
/**
5050
* Creates an authorized Credential object.
5151
* @param HTTP_TRANSPORT The network HTTP Transport.
5252
* @return An authorized Credential object.
53-
* @throws IOException If there is no client_secret.
53+
* @throws IOException If the credentials.json file cannot be found.
5454
*/
5555
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
5656
// Load client secrets.
57-
InputStream in = ClassroomQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
57+
InputStream in = ClassroomQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
5858
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
5959

6060
// Build flow and trigger user authorization request.
6161
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
6262
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
63-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(CREDENTIALS_FOLDER)))
63+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
6464
.setAccessType("offline")
6565
.build();
6666
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

drive/activity/quickstart/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'java'
22
apply plugin: 'application'
33

4-
mainClassName = 'ActivityQuickstart'
4+
mainClassName = 'DriveActivityQuickstart'
55
sourceCompatibility = 1.7
66
targetCompatibility = 1.7
77
version = '1.0'

0 commit comments

Comments
 (0)