0

Can someone please show a sample of doing auth for the Google Speech v1beta1 gRPC API on Android?

I'm trying to run the sample code in https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/speech.

It runs fine on OSX and within Eclipse; when I try on Android I get different results.

Specifically, in the part:

private ManagedChannel createChannel(String host, int port) throws IOException     {
    try {
        ...
        GoogleCredentials creds = ...
        creds = creds.createScoped(OAUTH2_SCOPES);

        ManagedChannel channel =
                ManagedChannelBuilder.forAddress(host, port)
                        .intercept(new ClientAuthInterceptor(creds, Executors.newSingleThreadExecutor()))
                        .build();

I get the complaint that ClientAuthInterceptor is deprecated, and in javadoc for io.grpc.auth it says "use GoogleAuthLibraryCallCredentials instead", which it appears is from https://github.com/grpc/grpc-java :any examples of success using that?

In OSX/Eclipse I'm using the sample code "as is" while on Android I'm reading the JSON Google credentials from a file, though the credentials returned seem similar.

Thanks!

DJCJ
  • 1
  • Have you tried the Android example https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech – brandall Oct 29 '16 at 14:11
  • using v1beta-java sample project not the best for android.... https://github.com/yurifariasg/android-google-speech-sample will be better choice for android.. Be very careful on mixing/matching any gRPC lib modules from java examples into the android project. Reason - many , many permutations of incompat dependencies among proto-buf , gRPC, and speechAPI exist. So, stick to the build env config'd for link project and be careful with any component upgrades among (grpc, protoBuf) . PS eclipse v AS... go with android studio and gradle – Robert Rowntree Oct 30 '16 at 14:56

0 Answers0