所以我修改了Google Speech API
示例代码(之前也没有工作)以与他们的更新通知(关于 中的弃用ClientAuthenticator
)相提并论,并得到与以前相同的错误但没有解决方案,主机是speech.googleapis.com/v1beta1/speech:asyncrecognize?key=My_Key
我的代码如下:
public static ManagedChannel createChannel(String host) throws IOException {
FileInputStream filestream = new FileInputStream("/home/admin/creds.json");
GoogleCredentials creds = GoogleCredentials.fromStream(filestream).createScoped(OAUTH2_SCOPES);
ManagedChannel channel = ManagedChannelBuilder.forTarget(host).build();
GreeterGrpc.GreeterStub stub = GreeterGrpc.newStub(channel);
stub = stub.withCallCredentials(MoreCallCredentials.from(creds));
System.out.println(channel.authority()+creds);
filestream.close();
return channel;
}
但它只是返回一个
WARNING: RPC failed: Status{code=PERMISSION_DENIED, description=The request cannot be identified with a client project. Please pass a valid API key with the request., cause=null}
欢迎任何帮助或建议,谢谢!