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

delombok.io.github.qsy7.google.CredentialsProvider Maven / Gradle / Ivy

The newest version!
package io.github.qsy7.google;

import com.google.auth.oauth2.ServiceAccountCredentials;
import io.github.qsy7.google.property.GoogleCloudAccessToken;
import io.github.qsy7.property.api.annotation.Property;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import jakarta.inject.Inject;
import jakarta.inject.Provider;

public class CredentialsProvider implements Provider {
  protected final ServiceAccountCredentials credentials;

  @Inject
  public CredentialsProvider(
      @Property(GoogleCloudAccessToken.class) String googleCloudAccessTokenFilename)
      throws IOException {
    credentials =
        ServiceAccountCredentials.fromStream(
            new BufferedInputStream(new FileInputStream(googleCloudAccessTokenFilename)));
  }

  @Override
  public ServiceAccountCredentials get() {
    return credentials;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy