![]() ![]() Public static void main(String.Allays will dance to a Record playing in a Jukebox. returns an authorized Credential object. LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build() Ĭredential credential = new AuthorizationCodeInstalledApp(flow, receiver).authorize("user") setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH))) HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES) GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( Build flow and trigger user authorization request. GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in)) Throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH) InputStream in = (CREDENTIALS_FILE_PATH) Private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) * 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" * If modifying these scopes, delete your previously saved tokens/ folder.Ĭollections.singletonList(DriveScopes.DRIVE_METADATA_READONLY) * 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 demonstrate use of Drive files list API */ Open the default adle file and replace its contents with the In the src/main/resources/ directory, copy the credentials.json file Mkdir -p src/main/java src/main/resources In your working directory, create a new project structure: gradle init -type basic Save the downloaded JSON file as credentials.json, and move the.The newly created credential appears under OAuth 2.0 Client IDs. The OAuth client created screen appears, showing your new Client ID and Client secret. This name is only shown in the Google Cloud console. In the Name field, type a name for the credential.Click Create Credentials > OAuth client ID.In the Google Cloud console, go to Menu menu > APIs & Services > Credentials. ![]() You must create a separate client ID for each platform. To authenticate as an end user and access user data in your app, you need toĬreate one or more OAuth 2.0 Client IDs. Registration looks OK, click Back to Dashboard.Īuthorize credentials for a desktop application
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |