I am using the Google API Storage API library. When I want to create a repository for creating a bucket:
private static Storage createStorage(String clientId, String clientSecret, String applicationName, Set<String> scopesList) {
HttpTransport httpTransport = null;
Storage storage;
Credential credential = null;
VerificationCodeReceiver receiver;
try {
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
} catch (GeneralSecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, jsonFactory, clientId, clientSecret, scopesList).build();
receiver = new LocalServerReceiver();
try {
credential = new AuthorizationCodeInstalledApp(flow, receiver).authorize(clientId);
} catch (IOException e) {
e.printStackTrace();
}
storage = new Storage.Builder(httpTransport, jsonFactory, credential).setApplicationName(applicationName).build();
return storage;
}
Windows opens my browser and displays this page:

The problem is that my code will be used on the server, so I want this step to be automatic. What to do?
source
share