Search in sources :

Example 36 with Credential

use of com.google.api.client.auth.oauth2.Credential in project gradle by gradle.

the class GcsClient method create.

public static GcsClient create(GcsConnectionProperties gcsConnectionProperties) throws GeneralSecurityException, IOException {
    HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
    JsonFactory jsonFactory = new JacksonFactory();
    Storage.Builder builder = new Storage.Builder(transport, jsonFactory, null);
    if (gcsConnectionProperties.requiresAuthentication()) {
        Supplier<Credential> credentialSupplier = getCredentialSupplier(transport, jsonFactory);
        builder.setHttpRequestInitializer(new RetryHttpInitializerWrapper(credentialSupplier));
    }
    if (gcsConnectionProperties.getEndpoint().isPresent()) {
        builder.setRootUrl(gcsConnectionProperties.getEndpoint().get().toString());
    }
    if (gcsConnectionProperties.getServicePath().isPresent()) {
        builder.setServicePath(gcsConnectionProperties.getServicePath().get());
    }
    builder.setApplicationName("gradle");
    return new GcsClient(builder.build());
}
Also used : HttpTransport(com.google.api.client.http.HttpTransport) GoogleNetHttpTransport(com.google.api.client.googleapis.javanet.GoogleNetHttpTransport) GoogleCredential(com.google.api.client.googleapis.auth.oauth2.GoogleCredential) Credential(com.google.api.client.auth.oauth2.Credential) Storage(com.google.api.services.storage.Storage) JsonFactory(com.google.api.client.json.JsonFactory) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory)

Aggregations

Credential (com.google.api.client.auth.oauth2.Credential)33 IOException (java.io.IOException)24 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)21 YouTube (com.google.api.services.youtube.YouTube)20 StoredCredential (com.google.api.client.auth.oauth2.StoredCredential)5 InputStreamContent (com.google.api.client.http.InputStreamContent)4 AuthorizationCodeInstalledApp (com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)3 LocalServerReceiver (com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver)3 GoogleAuthorizationCodeFlow (com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow)3 GoogleClientSecrets (com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets)3 MediaHttpUploader (com.google.api.client.googleapis.media.MediaHttpUploader)3 MediaHttpUploaderProgressListener (com.google.api.client.googleapis.media.MediaHttpUploaderProgressListener)3 FileDataStoreFactory (com.google.api.client.util.store.FileDataStoreFactory)3 ArrayList (java.util.ArrayList)3 Calendar (java.util.Calendar)3 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)2 HttpRequest (com.google.api.client.http.HttpRequest)2 DateTime (com.google.api.client.util.DateTime)2 Channel (com.google.api.services.youtube.model.Channel)2 ChannelListResponse (com.google.api.services.youtube.model.ChannelListResponse)2