|
38 | 38 | public class AdminSDKDirectoryQuickstart { |
39 | 39 | private static final String APPLICATION_NAME = "Google Admin SDK Directory API Java Quickstart"; |
40 | 40 | 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"; |
42 | 42 |
|
43 | 43 | /** |
44 | 44 | * Global instance of the scopes required by this quickstart. |
45 | 45 | * If modifying these scopes, delete your previously saved credentials folder at /secret. |
46 | 46 | */ |
47 | 47 | 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"; |
49 | 49 |
|
50 | 50 | /** |
51 | 51 | * Creates an authorized Credential object. |
52 | 52 | * @param HTTP_TRANSPORT The network HTTP Transport. |
53 | 53 | * @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. |
55 | 55 | */ |
56 | 56 | private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException { |
57 | 57 | // Load client secrets. |
58 | | - InputStream in = AdminSDKDirectoryQuickstart.class.getResourceAsStream(CLIENT_SECRET_DIR); |
| 58 | + InputStream in = AdminSDKDirectoryQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH); |
59 | 59 | GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in)); |
60 | 60 |
|
61 | 61 | // Build flow and trigger user authorization request. |
62 | 62 | GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( |
63 | 63 | 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))) |
65 | 65 | .setAccessType("offline") |
66 | 66 | .build(); |
67 | 67 | return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); |
|
0 commit comments