

Once you create the credentials, make sure the downloaded JSON file is saved asĬredentials.json. To learn how to create credentialsįor a desktop application, go to Create credentials. This error occurs when you have not authorized the desktop application credentialsĪs detailed in the Prerequisites section above. When running the sample, you might receive a file not found or no such file error regarding credentials.json. File not found error for credentials.json Private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException * IOException If the credentials.json file cannot be found. * HTTP_TRANSPORT The network HTTP Transport. * Creates an authorized Credential object. Private static final String CREDENTIALS_FILE_PATH = "/credentials.json" Private static final List SCOPES = Collections.singletonList(DriveScopes.DRIVE_METADATA_READONLY) * If modifying these scopes, delete your previously saved tokens/ folder.
* Global instance of the scopes required by this quickstart. Private static final String TOKENS_DIRECTORY_PATH = "tokens" ** Directory to store authorization tokens for this application. Private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance() Private static final String APPLICATION_NAME = "Google Drive API Java Quickstart" * class to demonstarte use of Drive files list API */ Open the default adle file and replace its contents with the Prerequisite into the newly-created src/main/resources/ Mkdir -p src/main/java src/main/resourcesĬopy the credentials.json file you downloaded as a Project structure: gradle init -type basic In your working directory, run the following commands to create a new A Google account with Google Drive enabled.To learn how toĬreate credentials for a desktop application, refer to Authorization credentials for a desktop application.Note: For this quickstart, you are enabling the "Drive API". A Google Cloud project with the API enabled.To run this quickstart, you need the following prerequisites: Complete the steps described in the rest of this page to create a simple JavaĬommand-line application that makes requests to the Drive API.
