All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.yudichev.jiotty.connector.google.drive.GoogleDriveProvider Maven / Gradle / Ivy

package net.yudichev.jiotty.connector.google.drive;

import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.drive.Drive;
import net.yudichev.jiotty.connector.google.common.GoogleAuthorization;

import javax.inject.Inject;
import javax.inject.Provider;

import static com.google.common.base.Preconditions.checkNotNull;
import static net.yudichev.jiotty.connector.google.common.impl.Bindings.Authorization;

public final class GoogleDriveProvider implements Provider {
    private final Provider googleAuthorizationProvider;

    @Inject
    public GoogleDriveProvider(@Authorization Provider googleAuthorizationProvider) {
        this.googleAuthorizationProvider = checkNotNull(googleAuthorizationProvider);
    }

    @Override
    public Drive get() {
        var credential = googleAuthorizationProvider.get().getCredential();
        return new Drive.Builder(credential.getTransport(), JacksonFactory.getDefaultInstance(), credential)
                .setApplicationName("jiotty")
                .build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy