Source:
public static void main(String[] args) throws Exception { final String clientSecretsJson = "client_secrets.json"; GenomicsFactory.OfflineAuth auth = null; try { Builder builder = GenomicsFactory.builder("gRPCExample"); auth = builder.build().getOfflineAuthFromClientSecretsFile(clientSecretsJson); } catch (FileNotFoundException fex) { System.out.println("Expecting to find " + clientSecretsJson + " file in " + "this directory and use it for authentication.\n" + "Please make sure your project is whitelisted for gRPC access and\n" + "generate and download JSON key for your service account.\n" + "You can do that in API & Auth section of the Developer Console."); return; } GenomicsChannel channel = GenomicsChannel.fromOfflineAuth(auth); ReferenceServiceV1BlockingStub refStub = ReferenceServiceV1Grpc.newBlockingStub(channel.getChannel()); SearchReferenceSetsRequest request = SearchReferenceSetsRequest.newBuilder().build(); SearchReferenceSetsResponse response = refStub.searchReferenceSets(request); for (ReferenceSet rs : response.getReferenceSetsList()) { System.out.println(rs.getAssemblyId()); } StreamingVariantServiceBlockingStub varStub = StreamingVariantServiceGrpc.newBlockingStub(channel.getChannel()); StreamVariantsRequest varRequest = StreamVariantsRequest.newBuilder() .setVariantSetId("3049512673186936334") .setReferenceName("chr17") .setStart(41196311) .setEnd(41277499) .build(); try { Iterator<StreamVariantsResponse> iter = varStub.streamVariants(varRequest); while (iter.hasNext()) { StreamVariantsResponse varResponse = iter.next(); System.out.println("Response:"); System.out.println(varResponse.toString()); System.out.println(); } System.out.println("Done"); } finally { channel.shutdownNow(); } }

Target:
public static void main(String[] args) throws Exception { final String clientSecretsJson = "client_secrets.json"; GenomicsFactory.OfflineAuth auth = null; try { Builder builder = GenomicsFactory.builder("gRPCExample"); auth = builder.build().getOfflineAuthFromClientSecretsFile(clientSecretsJson); } catch (FileNotFoundException fex) { System.out.println("Expecting to find " + clientSecretsJson + " file in " + "this directory and use it for authentication.\n" + "Please make sure your project is whitelisted for gRPC access and\n" + "generate and download JSON key for your service account.\n" + "You can do that in API & Auth section of the Developer Console."); return; } GenomicsChannel channel = GenomicsChannel.fromOfflineAuth(auth); ReferenceServiceV1BlockingStub refStub = ReferenceServiceV1Grpc.newBlockingStub(channel); SearchReferenceSetsRequest request = SearchReferenceSetsRequest.newBuilder().build(); SearchReferenceSetsResponse response = refStub.searchReferenceSets(request); for (ReferenceSet rs : response.getReferenceSetsList()) { System.out.println(rs.getAssemblyId()); } StreamingVariantServiceBlockingStub varStub = StreamingVariantServiceGrpc.newBlockingStub(channel); StreamVariantsRequest varRequest = StreamVariantsRequest.newBuilder() .setVariantSetId("3049512673186936334") .setReferenceName("chr17") .setStart(41196311) .setEnd(41277499) .build(); try { Iterator<StreamVariantsResponse> iter = varStub.streamVariants(varRequest); while (iter.hasNext()) { StreamVariantsResponse varResponse = iter.next(); System.out.println("Response:"); System.out.println(varResponse.toString()); System.out.println(); } System.out.println("Done"); } finally { channel.shutdownNow(); } }