Example usage for com.google.api.client.googleapis.auth.oauth2 GoogleClientSecrets getInstalled

List of usage examples for com.google.api.client.googleapis.auth.oauth2 GoogleClientSecrets getInstalled

Introduction

In this page you can find the example usage for com.google.api.client.googleapis.auth.oauth2 GoogleClientSecrets getInstalled.

Prototype

public Details getInstalled() 

Source Link

Document

Returns the details for installed applications.

Usage

From source file:com.google.cloud.genomics.gatk.common.grpc.GenomicsDataSource.java

License:Open Source License

private Channel initGenomicsChannel() throws FileNotFoundException, IOException, GeneralSecurityException {
    checkParamsForAuth(AUTH_REQUIREMENTS.CLIENT_SECRETS_ONLY);
    final GoogleClientSecrets secrets = GoogleClientSecrets.load(Utils.getDefaultJsonFactory(),
            new FileReader(clientSecretsFilename));
    final OfflineAuth auth = getFactory().getOfflineAuthFromClientSecretsFile(clientSecretsFilename);
    final UserCredentials userCredentials = new UserCredentials(secrets.getInstalled().getClientId(),
            secrets.getInstalled().getClientSecret(), auth.refreshToken);

    // Java 8's implementation of GCM ciphers is extremely slow. Therefore we disable
    // them here.
    List<String> defaultCiphers = GrpcSslContexts.forClient().ciphers(null).build().cipherSuites();
    List<String> performantCiphers = new ArrayList<>();
    for (String cipher : defaultCiphers) {
        if (!cipher.contains("GCM")) {
            performantCiphers.add(cipher);
        }/* ww  w . ja va2  s  . c o  m*/
    }

    channelImpl = NettyChannelBuilder.forAddress("genomics.googleapis.com", 443)
            .negotiationType(NegotiationType.TLS).streamWindowSize(1000000)
            .sslContext(GrpcSslContexts.forClient().ciphers(performantCiphers).build()).build();
    /*userCredentials = userCredentials.createScoped(
        Arrays.asList("https://www.googleapis.com/auth/genomics"));*/
    ClientAuthInterceptor interceptor = new ClientAuthInterceptor(userCredentials,
            Executors.newSingleThreadExecutor());
    return ClientInterceptors.intercept(channelImpl, interceptor);
}