简体   繁体   English

api 密钥与谷歌文档ai

[英]api key with google document ai

I am using the form parser of google document ai.我正在使用谷歌文档 ai 的表单解析器。 The only way to authenticate that I have found is through gcloud command interface ("Authorization: Bearer "$(gcloud auth application-default print-access-token)).我发现的唯一身份验证方法是通过 gcloud 命令界面(“Authorization: Bearer”$(gcloud auth application-default print-access-token))。

Our application uses Google Vision too and just needs an api key ( https://vision.googleapis.com/v1/images:annotate?key= )我们的应用程序也使用 Google Vision,只需要一个 api 密钥( https://vision.googleapis.com/v1/images:annotate?key=

How can I use this way google document AI?我怎样才能使用这种方式谷歌文档AI?

I have tried with the api key in /apis/credentials and I have tried to restrict the key to ip too and to document ai api, but all with the same result:我已经尝试使用 /apis/credentials 中的 api 密钥,我也尝试将密钥限制为 ip 并记录 ai api,但结果相同:

curl -v -X POST -H "Content-Type: application/json; charset=utf-8" -d @request.json https://eu-documentai.googleapis.com/v1beta3/projects/<project id>/locations/eu/processors/<processor id>:process?key=<api key>

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

What am I missing?我错过了什么?

Request is missing required authentication credential.请求缺少所需的身份验证凭据。

Means that you have not sent any authorization with your request表示您没有随请求发送任何授权

The request you are attempting requires that you send an access token along as a bearer token您尝试的请求要求您发送访问令牌作为不记名令牌

curl -H "Authorization: bearer <ACCESS_TOKEN>" http://www.example.com

You appear to only be sending an API key which will only grant you access to public data not private user data.您似乎只发送了一个 API 密钥,它只会授予您访问公共数据而非私人用户数据的权限。

The Document AI Quickstart shows how to setup Authentication for the Document AI API.文档 AI 快速入门展示了如何为文档 AI API 设置身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google API:将文档下载为 zip 文件 - Google API: Download document as zip file Google AI Platform 在线预测 - 使用 REST API 时权限被拒绝 - Google AI Platform Online Prediction - Permission Denied when using REST API 动态生成谷歌地图API键? - Dynamically Generate Google Maps API Key? 如何使用Curl和API密钥上传到Google云端存储? - How do I upload to Google Cloud Storage with Curl and an API key? 使用curl PHP的Google API密钥Http引用人问题 - Google API Key Http referrers issue using curl PHP 谷歌URL缩短器不能通过控制台中的卷曲与API密钥一起使用 - google url shortener not working with api key via curl in console 如何使用php和curl提供Google Maps API密钥 - How to provide Google Maps API key with php and curl Google Places API服务器密钥无法使用Curl - Google Places API server key doesn't work using Curl 带有cURL的Google Geocoding API请求被拒绝。 我有一个与启用了结算功能的项目关联的API密钥 - Google Geocoding API request with cURL denied. I have an API key associated to a project with billing enabled 卷曲POST请求从Google Places API返回错误。 “服务需要钥匙” - Curl POST request returning error from Google places API. “Service requires a key”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM