有人可以展示在 Android 上为 Google Speech v1beta1 gRPC API 进行身份验证的示例吗?
我正在尝试在https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/speech中运行示例代码。
它在 OSX 和 Eclipse 上运行良好;当我在 Android 上尝试时,我得到了不同的结果。
具体来说,在部分:
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();
我收到了 ClientAuthInterceptor 已被弃用的投诉,并且在 javadoc 中io.grpc.auth
说“改用 GoogleAuthLibraryCallCredentials”,它似乎来自https://github.com/grpc/grpc-java:任何成功使用它的例子?
在 OSX/Eclipse 中,我“按原样”使用示例代码,而在 Android 上,我正在从文件中读取 JSON Google 凭据,尽管返回的凭据看起来很相似。
谢谢!