Единственное отличие, которое я добавил:
Код: Выделить всё
DocumentProcessorServiceSettings ss = DocumentProcessorServiceSettings
.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(
GoogleCredentials.fromStream(
new FileInputStream(adcLocation)
)
)
)
.setEndpoint(endpoint)
.build();
- Поставщик учетных данных — в частности, json-файл ADC.
- Конечная точка как переменная — это потому, что некоторые из моих процессоров находятся в ЕС.
Код: Выделить всё
java.util.concurrent.ExecutionException: com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid location: 'eu' must match the server deployment 'us'
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:588)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:567)
at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:66)
at com.google.api.gax.longrunning.OperationFutureImpl.getName(OperationFutureImpl.java:136)
Код: Выделить всё
java.util.concurrent.ExecutionException: com.google.api.gax.rpc.UnauthenticatedException: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:588)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:567)
at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:66)
at com.google.api.gax.longrunning.OperationFutureImpl.getName(OperationFutureImpl.java:136)
Я также пытался отправить тот же запрос через Postman, но он работал как с documentai .googleapis.com и eu-documentai.googleapis.com и тот же ADC – за исключением того, что в Postman я использовал gcloud auth application-default print-access-token прежде чем копировать и вставлять его в токен носителя.
Подробнее здесь: https://stackoverflow.com/questions/760 ... icated-err
Мобильная версия