Skip to content

Commit af844e7

Browse files
author
Eric Koleda
committed
Change the file names expected for developer credentials and other changes.
1 parent d14d33b commit af844e7

File tree

16 files changed

+73
-75
lines changed

16 files changed

+73
-75
lines changed

.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

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/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'

drive/activity/quickstart/src/main/java/DriveActivityQuickstart.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ public class DriveActivityQuickstart {
4040
private static final String APPLICATION_NAME =
4141
"G Suite Activity API Java Quickstart";
4242

43-
/** Directory to store user credentials for this application. */
44-
private static final java.io.File DATA_STORE_DIR = new java.io.File(
45-
System.getProperty("user.home"), ".credentials/appsactivity-java-quickstart");
43+
/** Directory to store authorization tokens for this application. */
44+
private static final java.io.File DATA_STORE_DIR = new java.io.File("tokens");
4645

4746
/** Global instance of the {@link FileDataStoreFactory}. */
4847
private static FileDataStoreFactory DATA_STORE_FACTORY;
@@ -59,9 +58,7 @@ public class DriveActivityQuickstart {
5958
* If modifying these scopes, delete your previously saved credentials
6059
* at ~/.credentials/appsactivity-java-quickstart
6160
*/
62-
private static final List<String> SCOPES =
63-
Arrays.asList(AppsactivityScopes.ACTIVITY,
64-
AppsactivityScopes.DRIVE_METADATA_READONLY);
61+
private static final List<String> SCOPES = Arrays.asList(AppsactivityScopes.ACTIVITY);
6562

6663
static {
6764
try {
@@ -81,7 +78,7 @@ public class DriveActivityQuickstart {
8178
public static Credential authorize() throws IOException {
8279
// Load client secrets.
8380
InputStream in =
84-
DriveActivityQuickstart.class.getResourceAsStream("/client_secret.json");
81+
DriveActivityQuickstart.class.getResourceAsStream("/credentials.json");
8582
GoogleClientSecrets clientSecrets =
8683
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
8784

drive/quickstart/src/main/java/DriveQuickstart.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@
3838
public class DriveQuickstart {
3939
private static final String APPLICATION_NAME = "Google Drive 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.
4646
*/
4747
private static final List<String> SCOPES = Collections.singletonList(DriveScopes.DRIVE_METADATA_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 = DriveQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR);
58+
InputStream in = DriveQuickstart.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");

0 commit comments

Comments
 (0)